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 trialStefan Vaziri
17,453 PointsHelp!
I'm not sure how to add "World" to each word in the hellos list.
hellos = [
"Hello",
"Tungjatjeta",
"Grüßgott",
"Вiтаю",
"dobrý den",
"hyvää päivää",
"你好",
"早上好"
]
for hello in hellos:
if
4 Answers
Anish Walawalkar
8,534 PointsHey, you were on the right track there with the for loop.
for hello in hellos:
print("{} World".format(hello))
In the for loop I'm printing the string "{} World" and the format(hello) function just replaces {} with the string value of hello
Tobias Helmrich
31,603 PointsHey Stefan,
the beginning of your loop is correct. But you don't need an if here so you can remove that. To add the World to the "hello"s you can just concatenate the variable and the String " World" and print it out like this:
hellos = [
"Hello",
"Tungjatjeta",
"Grüßgott",
"Вiтаю",
"dobrý den",
"hyvää päivää",
"你好",
"早上好"
]
for hello in hellos:
print(hello + " World")
Anish Walawalkar
8,534 PointsIn your print statement it should be hello not word
Tobias Helmrich
31,603 PointsHey Anish,
I fixed this immediately after I sent it, I just had it different in my version and noticed that Stefan used hello instead of my word but forgot to change the second one. But thanks for the heads up! :)
Stefan Vaziri
17,453 PointsThanks you two! I tried both and both worked great!!
Tobias Helmrich
31,603 PointsNo problem, I'm glad you got it working! Happy coding! :)
Stefan Vaziri
17,453 PointsThanks you two! I tried both and both worked great!!