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

thanh trung
thanh trung
4,246 Points

remove(), and del()!! what wrong with my code

< 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.insert(1, 0)

the_list.remove("a") del the_list[4] del the_list[5]

help plz?

4 Answers

Neil Andruski
Neil Andruski
21,509 Points

Remember after you remove "a" from the list, 2 is now at the index of 0. Also make sure each remove or delete is on their own line. This is how your lines should look But you need to still change the deletes so the indexes are correct. I hope this hint helps and I'll respond if you need more help

< 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.insert(1, 0)

the_list.remove("a") # the_list = [2, 3, 1, False, [1, 2, 3]] after the remove

del the_list[4] 

del the_list[5]
thanh trung
thanh trung
4,246 Points

how do you do the code mark up like what you did above?

Neil Andruski
Neil Andruski
21,509 Points

Just below where you add a comment or answer there's a reference called markdown cheatsheet. Thats the easiest way to show you.

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Your code is fine for steps 1 and 2. Step 3 requires you to add items to the list so it holds all of the numbers from 1 to 20.

thanh trung
thanh trung
4,246 Points

this is what i got

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

#Your code goes below here

#this line will make my list like this

the_list.insert(0,the_list.pop(3))

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

the_list.remove("a") 

#After remove "a" the_list is gonna be liked this
# the_list = [1,2, 3, False, [1, 2, 3]] after the remove

del the_list[3]
#After remove boolean the_list is gonna be like this
# the_list = [1,2,3,[1,2,3]]

del the_list[3]
#After remove alist within a list at index 3 now

Is this a right code for this excerise? Please help!! when i run in IDLE , it works as it expected but when i run it in the workspace it throw error

Neil Andruski
Neil Andruski
21,509 Points

are you on part 3 of 3?

Neil Andruski
Neil Andruski
21,509 Points

Then so far everything is correct but now you need to make the list look like this

the_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 ,19, 20]

there are a few ways to go about it. So whichever way works for you try that.