Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

list.remove(1) returns ValueError but list.remove(5) is okay?

In the second list challenge I am correct and able to remove the number 5 from a list using the remove method but in the lecture before (and in my attempt in the workspace) I am not able to remove the number 1 from a list because of a returned ValueError?

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

Hi Rory,

I'm not sure I understand. There is no 1 to remove. There is a 5 in the list but there is no 1 in the list.

1 Answer

The example shows the challenge in which I was able to remove the number 5, but my workspace paused and reset so I am not able to show (nor understand) how I was not able to remove a number 1 from a list.

Sorry.

I retested it and I was successful in removing a number 1 from a list.

Thanks for taking a look Jason.