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 trialRyan Sladek
427 PointsHow do I add "World"?
I can't figure out how to add the word "World" to the loop for each hello in a language.
hellos = [
"Hello",
"Tungjatjeta",
"Grüßgott",
"Вiтаю",
"dobrý den",
"hyvää päivää",
"你好",
"早上好"
]
for hello in hellos:
print(hello)
1 Answer
Steven Parker
231,271 PointsThere's two ways I can think of offhand:
- you could use the format function
- you could use simple string concatenation (+)
Ryan Sladek
427 PointsRyan Sladek
427 PointsThanks Steven. I've tried:
but it says there is a syntax error.
Edit I figured it out. Thanks for the help!
Steven Parker
231,271 PointsSteven Parker
231,271 PointsThat's exactly what I was hinting in the second suggestion. I even pasted your code into the challenge and it passed.
Were you careful to add that code after the provided array, and not make any changes to the array itself?