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 (Retired) Lists Redux Combining Lists

Combine list_1 and list_2 into a new variable named list_3. You can combine lists the same way you combine strings.

hi. help please. how do i combine list_1 and list_2. whats wrong with code list_1 = [1, 2, 3] list_2 = ["Hello", 5, {}] list_3 = [1, 2, 3] + ["Hello", 5, {}]

lists.py
list_1 = [1, 2, 3]
list_2 = ["Hello", 5, {}]
list_3 = [1, 2, 3] + ["Hello", 5, {}]

2 Answers

Hie. You combine the two lists using (+), just like the way you do it when combining strings:

list_1 = [1, 2, 3]

list_2 = ["Hello", 5, {}]

  #now, combine both lists
list_3 = list_1 + list_2 
Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

You're right, that should pass. Dicts are, unfortunately, unhashable so how I was testing it was throwing an uncaught exception. I've updated it and your code should pass just fine now.

Thanks for finding this!