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 trialSilvie Cinkova
1,742 Pointswhat to do exactly?
is the output supposed to be empty, or a list with an empty list? Not sure about bracketing in your task: a) Use .remove() and/or del to remove [the string, boolean, and list] members of the_list or b) Use .remove() and/or del to remove the string, boolean, and [list members] of the_list ??? Thank you!
1 Answer
Chris Freeman
Treehouse Moderator 68,441 PointsIn each task, the goal is to operate on the_list
to modify it according to the instructions. There are many operations that operate on a list "in place" which means changing the_list
without reassigning to another variable. Your code will be a series of statement affecting the_list
. List methods to use are:
-
.pop()
removes the last item from a list, -
.pop(index)
removes the item from a list at that index - `.insert(index, item) inserts an item into list at position index
- `.remove(item) removes the first occurrence of that item from list
- `.extend(list) extends a list with the members from another list
For example:
the_list = ["a", 2, 3, 1, False, [1, 2, 3]]
# Remove the '1' from the list
the_list.pop(3)
# Insert the '1' into the first position
the_list.insert(0, 1)
# or in one step
the_list.insert(0, the_list.pop(3))
You solution will be a series of these list altering statements. Post back if you need more hints.
Silvie Cinkova
1,742 PointsSilvie Cinkova
1,742 PointsSo it's a)? I am not supposed to alter the embedded list except delete it? I am perhaps over-thinking it, but altering the embedded list is also a possible alteration of the_list, isn't it? I seem to be unable to solve either anyway, and that's why I decided to beg for full solution in another post. I have really tried hard, but now I have to move on. Thanks for your prompt reply!
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsI've posted a solution to your other question. In short, the challenge is about manipulating the given list through a series of statements. Each statement making an individual change, but when run all together manipulate the list to the goal of the challenge.
Parvinder Grewal
3,678 PointsParvinder Grewal
3,678 PointsThank you for those bullet points. That helped me solve a question.