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 trial

Python Python Basics (2015) Logic in Python Loop

syntax error in for loop challenge

trying to print to the results of a for loop on a list of words called "hellos" followed by the word "world"

this doesn't work:

for word in hellos: print (word "World")

tried various quote combos and anything else I could think of\ Stuck

loop.py
hellos = [
    "Hello",
    "Tungjatjeta",
    "Grüßgott",
    "Вiтаю",
    "dobrý den",
    "hyvää päivää",
    "你好",
    "早上好"
]
for word in hellos:
    print (word "World")

2 Answers

Steven Parker
Steven Parker
231,275 Points

:point_right: You forgot the concatenation operator (+)

When you join strings together, you use the concatenation operator (+) between them.

Also remember to include a space inside the quotes and before World.

Ben Shockley
Ben Shockley
6,094 Points

When you embed variables into a string you would use a format sequence. For strings you would use %s, and then place the variable at the end of the string. So your print statement would look like this.

print("%s World" % word)

Thanks Ben you're a life saver.