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 trialSUDHARSAN CHAKRAVARTHI
Courses Plus Student 2,434 Pointslist manipulation
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 [:]
Like to know what's the wrong in above code?.
And i tried below code too:
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)
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 [:]
6 Answers
Andrew K
13,774 PointsHi there Sudharsan,
Your first four lines of code are just fine, but the final step of the challenge asks you to use the extend
function to make your list contain a range
from 1 to 20.
Kenneth Love
Treehouse Guest TeacherWhat do you think the del the_list [:]
line is doing?
SUDHARSAN CHAKRAVARTHI
Courses Plus Student 2,434 Pointsi used to delete remaining contents in the list. Since i missed to delete the list [1 2 3 ] inside the list. i was given error message. Thank You very much.
Kenneth Love
Treehouse Guest Teacherdel the_list [:]
would delete a copy of the_list
.
SUDHARSAN CHAKRAVARTHI
Courses Plus Student 2,434 Pointsdel the_list [:] will delete only the contents right?. or the even it deletes the list "the_list". Confirm my understanding.
Kenneth Love
Treehouse Guest TeacherIt will delete the contents of the list, yes. You don't need to delete the contents of the list, though.
Tony McCabe
4,889 Pointsthe_list = ["a", 2, 3, 1, False, [1, 2, 3]] love = the_list.pop(3) the_list.insert(0,love) the_list.remove([1, 2, 3]) the_list.remove(False) del the_list[1] the_list.extend(range(3,21)) this code does not seem to be working... Say's bummer???
SUDHARSAN CHAKRAVARTHI
Courses Plus Student 2,434 PointsYes. i solved it with the help of forum members. now forgot the question. can you ping me the task needs to be completed on the given list. so that i can help my best...
Example code : the_list.insert(0,the_list.pop(3)) the_list.remove('a') the_list.remove(False) del the_list[:]
Modify the code according to your task.
Tara Edwards
6,521 PointsTara Edwards
6,521 PointsSo, does that mean that I do not have to determine type? Because I have made an elaborate '''if''' statement based on the result of '''type(item in list)'''.
Kenneth Love
Treehouse Guest TeacherKenneth Love
Treehouse Guest TeacherTara Edwards you do not have to worry about types to complete this challenge. You can, of course, but you're making it harder than it has to be.