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 trialilya A
3,802 Pointsi need help, I'm confused
I don't know how to Add them together?
beatles = ["John"]
others = ["George", "Ringo"]
beatles.append("Paul")
others.append("john")
all_list = others + beatles
1 Answer
andren
28,558 PointsThe previous video showcased three list techniques:
- Appending, which adds an item to a list
- Extending, which adds the items of one list to another
- Concatenating, which creates a new list by combining other lists
In task 2 you are asked to add all the items from the other
list to the beatles
list. The ideal way of doing that is by extending the beatles
list. Like this:
beatles = ["John"]
others = ["George", "Ringo"]
# Your code here
beatles.append("Paul")
beatles.extend(others) # Add all of the items from the other list into the beatles list