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 Collections (Retired) Lists Redux Manipulating Lists

remove items from the list

As per given task, i cleared the character , then removed the Boolean and removed all the list members using the function del. unable to find what's wrong with the implementation.

lists.py
the_list = ["a", 2, 3, 1, False, [1, 2, 3]]

# Your code goes below here
the_list.insert(0,the_list.pop(3))
the_list.remove('a')
the_list.remove(False)
del the_list[:]

3 Answers

There's problem in your last line of code del the_list[:], what it does is basically deleting EVERY items in the the_list, after that line, the_list just becomes an empty list. here's what you should do instead.

the_list.remove([1,2,3])

the_list = ["a", 2, 3, 1, False, [1, 2, 3]]

Your code goes below here

the_list.insert(0,the_list.pop(3)) the_list.remove('a'); the_list.remove(False) the_list.remove([1,2,3]) del the_list [:]

Version 2:

Your code goes below here

the_list.insert(0,the_list.pop(3)) the_list.remove('a'); the_list.remove(False) the_list.remove([1,2,3]) the_list.remove(2) the_list.remove(3) the_list.remove(1)

Both the versions has some issue. Unable to point the error.

get rid of this line del the_list [:]; this line totally destroy your list.

l think your code is correct if you want to clear all the items in the_list. But l think the challenge requires you to clear the list inside the_list, that is the last item [1,2,3].

the_list = ["a", 2, 3, 1, False, [1, 2, 3]]

Your code goes below here

the_list.insert(0,the_list.pop(3)) the_list.remove('a'); the_list.remove(False) the_list.remove([1,2,3]) del the_list [:]

still there is some issue with my code?. Can you help ?.