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 trialPatricia Taylor
2,228 PointsI'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")
2 Answers
Gianmarco Mazzoran
22,076 PointsHi,
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
jcorum
71,830 PointsPatricia, 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.