Jebadeiah Jones6,329 Points
How to check if item in messy_list is an integer.
I guess I'm gonna just go one-by-one and remove each item. I know how to pass this. I just don't like it.
There's gotta be a way to use a for loop to check if each item in messy_list is an integer or not, move on if it is and remove it if it's not. For some reason, my code deletes all of the contents of messy_list. What am I doing wrong?
messy_list = ["a", 2, 3, 1, False, [1, 2, 3]] # Your code goes below here messy_list.insert(0, messy_list.pop(3)) for item in messy_list.copy(): if item == int: print(item) continue else: messy_list.remove(item)
Steven Parker201,292 Points
You've got the right idea, but you don't want to compare the item itself with a type. Plus, this is an occasion to use the identity operator ("is"):
if type(item) is int: