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 (2016, retired 2019) Lists Creating lists


For so many of the excersises i've had to look up the answer now, and this is just one of them

This challenge is just meant as a refresher. Create a single new list variable named my_list. Put 3 numbers and 2 strings into it in whatever order you want. For the last member, though, add another list with 2 items in it.

my_list = [1,2,3,"Apple","Pear"]

1 Answer

28,558 Points

This particular challenge do tend to trip up a lot of students so you don't have to feel too bad about being stuck on it. The key to this challenge is understanding that a list can contain any item, including lists. So you can place a list inside a list.

The challenge wants the last item to be a list which contains two items, like this:

my_list = [1,2,3,"Apple","Pear", ["Nested string 1", "Nested string 2"]]

In the above code I have added the following list ["Nested string 1", "Nested string 2"] as a single item in my_list. This is something which often looks odd to people starting programming, but is entirely valid. And is not actually that uncommon to find in real programs.

Thanks for the help on this particular problem, but my main problem is that I keep having to look up most of these answers, IM STUCK ugh