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 trialChris Woods
1,928 PointsNot 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 = ["John"]
others = ["George", "Ringo"]
beatles.append("Paul")
beatles.extend (["beatles", "others"])
2 Answers
Steven Parker
231,275 PointsAnything 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.
Chris Woods
1,928 PointsThat explained it. Thanks Steven Parker
Chris Woods
1,928 PointsChris Woods
1,928 PointsOk, 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
231,275 PointsSteven Parker
231,275 PointsWhen using "extend" to add one list onto another, the syntax looks like this:
another.extend(onelist)