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

Didier Borel
Didier Borel
2,837 Points

didn't find all the words in a list

I don't understand why I get this error message-

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

Hello Didier Borel, great job, you have almost understod.

WORD is an placeholder for each value of the list, you put it out of the quotation marks because is a variable not a litteral

3 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

I really don't know what to say. Here's the entirety of the code copy/pasted from my passing challenge.

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

for word in hellos:
  print (word + " World")
Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Your for loop isn't doing what you think it's doing. In your current code, the for loop will print this out to the screen "word World" and it will print that 8 times. Exactly those words. What you want is for it to print the word from the hellos list then print "World" afterwards. This is the for loop you're looking for.

for word in hellos:
  print (word + " World")
Didier Borel
Didier Borel
2,837 Points

Jennifer, this for your quick answer, but when I do that. I still get the error message "can't find all the hello's" i don't understand why

Didier Borel
Didier Borel
2,837 Points

it works now! thxs, the problem must have been the indentation after the :

this