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

Not sure how to add "beatles" to "others" correctly

Ive watched the video a few times, and I am not understanding why beatles.extend(["beatles", "others"]) isn't the right way to do this. any help is appreciated.

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

2 Answers

Steven Parker
Steven Parker
231,275 Points

Anything in quotes is a literal string and only represents the characters between the quotes. Quotes should never be put around a variable or parameter name.

Also, when you extend beatles, you wouldn't want beatles as part of the argument. And since others is already a list, it won't need to be enclosed in brackets.

Ok, I'm following what you're saying about quote strings, but I'm still not understanding how to format the .extend to work properly in this case. I've tried several iterations trying to get it to work, but I think I'm missing something fundamental here.

Steven Parker
Steven Parker
231,275 Points

When using "extend" to add one list onto another, the syntax looks like this:

    another.extend(onelist)

That explained it. Thanks Steven Parker