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

Pratik Pawde
Pratik Pawde
1,745 Points

can someone please help me with this code I am not able to remove the list from the original list

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

Your code goes below here

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

for m in messy_list: if type(m) == str or type(m) == bool or type(m) == list: messy_list.remove(m)

messy_list

lists.py
messy_list = ["a", 2, 3, 1, False, [1, 2, 3]]

# Your code goes below here
messy_list.insert(0, messy_list.pop(3))

for m in messy_list:
    if type(m) == str or type(m) == bool or type(m) == list:
        messy_list.remove(m)

messy_list

1 Answer

Pratik Pawde
Pratik Pawde
1,745 Points

it worked when I copied the original list and used that in the for loop. Thanks anyway :)