Python Python Basics (2015) Python Data Types list.remove()

Keep getting Value error, supposed to remove last item from list.

Would like to see what i'm doing wrong?

lists.py
states = ['ACTIVE', ['red', 'green', 'blue'],'CANCELLED','FINISHED', 5]
states.remove([5])

1 Answer

Stuart Wright
Stuart Wright
41,066 Points

You need to remove the square brackets.

Your current code is attempting to remove an inner list from within the main list, and such an inner list does not exist. You just need to pass the integer 5 to the remove method.

However, I get a error saying Bummer! Don't change states directly!

Stuart Wright
Stuart Wright
41,066 Points

states.remove(5) works correctly for me. Maybe reset any changes you had previously made and try it again? It's possible that you accidentally edited the existing line and it causes the challenge to fail.