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 trialGábor Tóth
11,958 PointsNeed help with Quiz Question!
Hi! I've bumped into this quiz question, and I'm unable to solve it. I can't figure out what the exercise wants me to do. I've tried everything, but I still can't pass the question.
#Copy the entire list with a slice.
a_list = [1, 2, 3]
a_list = #The code goes here.
Thanks for your help.
1 Answer
andren
28,558 PointsThe challenge wants you to make a slice that includes the entire list, in essence making an exact copy of the list. Doing so is pretty simple. The slice needs to start at the beginning of the list, and end at the end of the list.
Since the "default" starting value of a slice is the beginning, and the "default" ending value is the end of the list you can actually just do an empty slice like this:
a_list[:] # Slice with default starting and ending value
And that will result in a slice that contains the entire list. On a side note it's worth mentioning that the quiz does not want you to assign anything to a_list
, only to demonstrate the slice. So the answer to the Quiz is simply [:].