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 Introducing Lists Meet Lists All You Need Is Lists

i need help, I'm confused

I don't know how to Add them together?

beatles.py
beatles = ["John"]
others = ["George", "Ringo"]
beatles.append("Paul")
others.append("john")
all_list = others + beatles

1 Answer

andren
andren
28,558 Points

The previous video showcased three list techniques:

  1. Appending, which adds an item to a list
  2. Extending, which adds the items of one list to another
  3. 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