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()

Sim Jia Yang
PLUS
Sim Jia Yang
Courses Plus Student 1,598 Points

list.remove challenge part 2 HELP

Hi, could any1 check my code and see what's wrong with it?

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

3 Answers

Ignazio Calo
PLUS
Ignazio Calo
Courses Plus Student 1,819 Points

Of course to pass the challenge you need to remove both the elements:

states = [
    'ACTIVE',
    ['red', 'green', 'blue'],
    'CANCELLED',
    'FINISHED',
    5,
]
states.remove(5)
states.remove(['red', 'green', 'blue'])
Ignazio Calo
PLUS
Ignazio Calo
Courses Plus Student 1,819 Points

The remove() function accept only one parameter as you can see here on the documentation.

https://docs.python.org/3/library/array.html?highlight=remove#array.array.remove

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

works as expected

Sim Jia Yang
Sim Jia Yang
Courses Plus Student 1,598 Points

Okay. But if i just add only

states.remove(['red', 'green', 'blue'])

I still cant get the correct ans. Cheers.

When I try to copy your code it passes. Have you done each removal on a separate line? E.g

states.remove(5) states.remove(['red', 'green', 'blue'])

If so, it should pass.