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 trialDeVante Marshall
1,974 PointsHow do you use the remove function without affecting previous removals? I am having issues with the removal exercise.
Below is what I'm using. However, it seems that the first removal is no longer valid after I input the second (from what the exercise is telling me).
states.remove(5) states.remove([red, green, blue])
states = [
'ACTIVE',
['red', 'green', 'blue'],
'CANCELLED',
'FINISHED',
5,
]
states.remove(5)
states.remove[red, green, blue]
2 Answers
andren
28,558 PointsThe first removal is fine, the reason why task 1 no longer passes after you enter your code for task 2 is that your code has syntax errors in it, which invalidates all of your code as far as the code checker is concerned.
There are two errors in your code:
- When you call a method like
remove
you need to place parenthesis after it, and pass the argument within those parenthesis. - The words
red
,green
andblue
are strings so you need to wrap them in quote marks.
Like this:
states = [
'ACTIVE',
['red', 'green', 'blue'],
'CANCELLED',
'FINISHED',
5,
]
states.remove(5)
states.remove(['red', 'green', 'blue']) # Added () around argument and quotes around strings.
DeVante Marshall
1,974 PointsGotcha. Thank you!