Removing Elements From Lists


I am having trouble with this lesson, I keep getting an error that says "It looks like your list is [] instead of [3, 5]."
My code is:
n = [1, 3, 5]

Removes 1 from the list,

NOT the item at index 1


Another possible solution, will remove the item at the given index:


Another possible solution will remove the item at index from the list and return it to you:

print n


You seem to have 3 ways of removing things. However, you are actually removing all three items of the list per way.
Such as n.remove(1) will remove the 1 in the list.
del(n[0]) will remove the 3 (since it is not the first item at index 0 after removing 1)
n.pop(0) removes the 5 since it is the only item left and is not at index 0 after removing 1 and 3.

Just pick one of those methods. That's all.


Thanks for the help!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.