下面是我想要分隔字符串和整數的列表。從列表中刪除整數+ python
這份名單給了我正確的結果:
list_a = ["Michell",123,"Apple","Food",456,"Another"]
list_e = []
x = 0
for item in list_a:
print("x is: ", x)
print("item is: ", item)
if isinstance(item,int):
list_e.append(item)
list_a.pop(x)
x+=1
print(list_a)
print(list_e)
當我一個元素添加到列表類似下面的問題開始: 添加的元素後,3231 ... 456
>>> list_a = ["Michell",123,"Apple","Food",456,3231,"Another"]
...
['Michell', 'Apple', 'Food', 3231, 'Another']
[123, 456]
是什麼這裏的問題?
FYI:我不能編輯其他人的帖子,但'intergers'是標題中的拼寫錯誤! –