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

I'm not sure how to make this for loop work. I've tried several ways shown in the video but can't find the right one.

I have tried several different for loops and cannot figure out exactly what I'm doing wrong. I get syntax errors and I get errors saying that it can't find all the "Hellos"

hellos = [
    "dobrý den",
    "hyvää päivää",

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

2 Answers

Gianmarco Mazzoran
Gianmarco Mazzoran
22,076 Points


with your for loop the output would look like this:

dobrý denWorld
hyvää päivääWorld

You need to add a space before the word "Hello":

for word in hellos:
    print(word + " World") # add a space before the word "World"

so the output would be:

Hello World
Tungjatjeta World
Grüßgott World
Вiтаю World
dobrý den World
hyvää päivää World
你好 World
早上好 World

Patricia, just a note, in case you aren't aware of this. To see what Gianmarco said you output would look like, you click the Preview button after you get a Bummer. it will show compile errors, if there are any. If there aren't, it will often (but not always) show output. In this case you code compiles and runs. So it shows output.