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 Basics (2015) Logic in Python Loop

MacKenzie T. Stout
MacKenzie T. Stout
23,972 Points

Cannot concatenate "str" to list?

Am receiving this bummer, "can only concatenate list (not "str") to list"

loop.py
hellos = [
    "Hello",
    "Tungjatjeta",
    "Grüßgott",
    "Вiтаю",
    "dobrý den",
    "hyvää päivää",
    "你好",
    "早上好"
]
for hello in hellos:
  print(hellos + " World")

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Close doesn't begin to describe it. I don't think you can get any closer without actually getting it right!

Take a look:

for hello in hellos:
  print(hello + " World")

You've said to print hellos... Keep in mind that hellos is the entire list of strings. The variable hello holds one single greeting from that list which is what we're after :smiley:

MacKenzie T. Stout
MacKenzie T. Stout
23,972 Points

I thought I understood it, couldn't figure out what I was doing wrong, thank you!!

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

MacKenzie Stout You're quite welcome! But to be fair, you could've understood it perfectly and the typo monster got you. Happens to me a lot! :thumbsup: