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

for loops

can't figure it out

loop.py
hellos = [
    "Hello",
    "Tungjatjeta",
    "Grüßgott",
    "Вiтаю",
    "dobrý den",
    "hyvää päivää",
    "你好",
    "早上好" ]


for words in hellos:
    print('word' + 'World')

3 Answers

I figured it out, I was missing the space before the word world.

and the s on words.

Neil, you're very close:

for hello in hellos:
  print(hello + " world")

Here I use hello for the variable. You create words but never use it. You probably meant to have words instead of word here: print('word' + 'World'), instead of 'word'. Note that you cannot quote the loop variable, even when you spell it right.

You are using "words" and then printing 'word'. Change words to word and remove the ' from the 'word' in print to print the variable instead of 'word'

for word in hellos:
    print(word + 'World')