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

Jo Mc
Jo Mc
4,591 Points

How do you remove more than one string from a list?

2.2. of lists exercise. How do you remove more than one string from the list? I have tried every way I feel I possibly could and there is still an issue with submitting it!

Any help would be appreciated!

Thank you!

1 Answer

Thomas Fildes
Thomas Fildes
22,687 Points

Hi Jodie,

This challenge can be quite a tricky one. Please see the below code which I used to pass this challenge:

states = [
    'ACTIVE',
    ['red', 'green', 'blue'],
    'CANCELLED',
    'FINISHED',
    5,
]

states.remove(states[len(states) - 1]) # removes last item

states.remove(states[1]) # removes second item

Here I have removed the last item of the list which will always have the index: length of the list -1, and I have removed the second item (index 1) from the list too.

Hope this helps! Happy Coding!!!

Jo Mc
Jo Mc
4,591 Points

Thank you so much! I actually managed to do it just after posting this! It really is difficult!