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 trialSam Royal
564 PointsWhat's wrong with this code?
Don't know what I did wrong here.
hellos = [
"Hello",
"Tungjatjeta",
"Grüßgott",
"Вiтаю",
"dobrý den",
"hyvää päivää",
"你好",
"早上好"
]
for word in hellos:
print(word + "World")
1 Answer
Michael Dinnall
6,730 PointsHey, Sam! your code works but the code challenge wanted you to place a space between the word and the word hello. Try one of these codes. both works for this code challenge.
for word in hellos:
print("{} World".format(word))
OR like the one you used but with the space that's needed.
for word in hellos:
print(word + " World")
Let me know how those work for you.
Vladimir Vasconcelos
Courses Plus Student 6,433 PointsVladimir Vasconcelos
Courses Plus Student 6,433 PointsI agree with Michael but you need to be aware that in the first case you just format the word and in the second example you could get problems with the sum of one variable with the string type of "World". It may be not a problem in this case but is nice to be aware of operations with different type of variables ;)