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 trialrsa14
1,865 PointsHow to add new list as a member of the original list?
I'm confused by this question. I know how to append and extend lists using the list.append/extend method, but here it says it wants the last member of the list to be another list itself. I can add things to a list, but it keeps saying "wrong number (not 6) of things." It's more of a technicality, what did you do?
My code attached has the .extend method, but I also tried the .append method before.
my_list = ["3", "2", "1", "string", "otherstring", ]
my_list.extend("item")
1 Answer
Alexander Davison
65,469 PointsYou don't need to "extend" or "append" anything. The challenge simply wants the last item of the list to be another list (so that the list contains an inner list) containing two items.
Also, when the challenge says "numbers", it actually means a literal integer.
my_list = [11, 8, 9, 'a', 'b', [1, 2]]
rsa14
1,865 Pointsrsa14
1,865 PointsNever mind I got it! Sorry I can't delete this, dumb question haha.
Forgot that you could simply bracket another list inside brackets themselves. I put quotes around the numbers just to try, even though quotes are only for strings. Overthinking on my part, still have a lot to learn.
my_list = [3, 2, 1, "sting", "otherstring", ["item", "otheritem"]]