Not super experienced, but I'm running into what looks like an error while using the isdigit() method.
I am trying to go through a list and remove all non-numbers, however my final list keeps giving me some letters. Not sure if this is a bug or I'm doing something wrong.
Here is my current python:
Python 3.6.1 (v3.6.1:69c0db5050, Mar 21 2017, 01:21:04)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
My code:
>>> test
['b', 'd', 'f', 'h', 'j', 'l', 'x', '2']
>>> for i in test:
if not i.isdigit():
print(i, "should not be a digit")
test.remove(i)
b should not be a digit
f should not be a digit
j should not be a digit
x should not be a digit
>>> test
['d', 'h', 'l', '2']
Here I would expect to only have 2 in my final list. Am I doing things wrong?