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

abhishek krishna vandadi
abhishek krishna vandadi
878 Points

isnt my code right?

isnt my code right?

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

# Your code goes below here
name_1=messy_list.pop(2)
messy_list.insert(0,1)

1 Answer

Sydney O'Reilly
Sydney O'Reilly
3,183 Points

There are two problems here. First, you're assigning the variable named name_1 the value of 3, (the item at index 2 in the messy_list) and popping that out of messy_list. The instructions say to remove the list item at index 3. And is it necessary to assign that value to a variable if you never use that variable in your code? Second, technically you're inserting the right value into the list at the right index, but instead of manually specifying the value of 1, couldn't you just instead insert the value of whatever happens when you pop the item at index 3? (what you did on your first line)