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
Benjamin Lopez
3,022 PointsRemoving list
Not sure what I am doing wrong here but I know it might be something easy.
states = [ 'ACTIVE', ['red', 'green', 'blue'], 'CANCELLED', 'FINISHED', 5, ] states.remove('blue')
5 Answers
Christopher Shaw
Python Web Development Techdegree Graduate 58,248 PointsThis will remove all nested 'blue'.
for state in states:
try:
state.remove('blue')
except ValueError:
pass
Jeremy Hill
29,567 PointsI think that the method is considering the red green and blue one single item.
Levis Vazquez
961 PointsSo did anybody got it working ? I'm stock here :/
Jeremy Hill
29,567 PointsYou could try this:
states = [ 'ACTIVE', ['red', 'green', 'blue'], 'CANCELLED', 'FINISHED', 5, ]
color = states[1]
color.remove('blue')
print(states)
Christopher Shaw
Python Web Development Techdegree Graduate 58,248 PointsCan you post / link the question, as I am not sure what you are trying to achieve
Levis Vazquez
961 PointsI got it working already. thanks