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!
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
Patricia Taylor2,228 Points
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 = [ "Hello", "Tungjatjeta", "Grüßgott", "Вiтаю", "dobrý den", "hyvää päivää", "你好", "早上好" ] for word in hellos: print(word + "World")
Gianmarco Mazzoran22,076 Points
with your for loop the output would look like this:
HelloWorld TungjatjetaWorld GrüßgottWorld ВiтаюWorld dobrý denWorld hyvää päivääWorld 你好World 早上好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.