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

Swan The Human
seal-mask
.a{fill-rule:evenodd;}techdegree
Swan The Human
Full Stack JavaScript Techdegree Student 19,338 Points

String refresher. Trying to remember how to add a list of two items into a list.

not sure whether i should do it directly inside the first list or append it into the original list on another line. it wasnt technically covered just directly placing a list inside of another one

lists.py
my_list = ['1', '2', '3', 'number', 'letter', ['string', 'strings']]

1 Answer

Kyle Petran
Kyle Petran
5,017 Points

I think this question really depends on what you're trying to accomplish. I believe a .append function would be something you might use to add something to an already existing list; however, if the list element that you want to add to your list is needed at the time of declaration then you would declare the variable the way you did so above. Hope this helps.