Python Python Collections (2016, retired 2019) Lists Removing items from a list

Messy List

messy_list = ["a", 2, 3, 1, False, [1, 2, 3]]

messy_list.insert(1, messy_list.pop(3))

messy_list.remove("a") messy_list.remove(False) messy_list.remove([1, 2, 3]) print(messy_list)

1 Answer

Hey Parvati! You have not asked an actual question, please make sure to do this in the future. That being said im assuming your trying to ask why your code dosent pass.

Two things are wrong with your code. 1) You were asked to insert what is contained at index 3 of the list (the number 1), to position 0 in the list. You have moved it to position 1.

2) Your printing the list at the end of your code, but you were never asked to do that, and so it wont pass either (never do anything in the code challenges unless you were explicitely asked to do so)

At the end your code should look like this:

messy_list = ["a", 2, 3, 1, False, [1, 2, 3]]

messy_list.insert(0, messy_list.pop(3))

messy_list.remove(False)
messy_list.remove("a")
messy_list.remove([1,2,3])

Hope this helps!