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

Noah Harness
Noah Harness
1,383 Points

Python Flask .remove on lists

"it looks like Task 1 is no longer working" I know how to do all this but I think the treehouse course is requiring some syntax that it didn't teach me.........HELP PLEASE

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

1 Answer

Vidhya Sagar
Vidhya Sagar
1,568 Points

Why are your removing Cancelled ? It's not in the challenge. It has asked you only to remove the list of ['red', 'green', 'blue']. And you need not speicfy 5 within a list like [5] , it means the python compiler will seach within the list , for a list with 5 in it . IF the list has elements like [1,2,3,4,[5]] Then using .remove([5]) is correct . If its a normal list like [1,2,3,4,5] ,then using .remove(5) is enough .Try this.Cheers

states = [
    'ACTIVE',
    ['red', 'green', 'blue'],
    'CANCELLED',
    'FINISHED',
    5,
]
#for Code Challenge 1:
states.remove(5)
#for Code Challenge 2:
states.remove(['red', 'green', 'blue'])
Noah Harness
Noah Harness
1,383 Points

Yeah I misread it. Not to self. Do not do this right after getting up.