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 loop

help am stuck

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

]
for hellos in list:
    print(hellos)

2 Answers

Hi there,

You want to iterate through hellos, so that comes after the in. It is the list!

So, you have a list of words. You want to pull out each word in turn from that list. You use a for loop.

for word in hellos:

This will work through all of hellos and put each word in the word variable. In this challenge you want to print out the word plus " World". So you need to amend your print command a little to print word + " World".

Something like:

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

I hope that helps,

Steve.

thanks steve

No problem! :+1: :smile:

Antonio De Rose
Antonio De Rose
20,885 Points
for hellos in list:
    print(hellos)

# 1st -> in python, first comes the working variable, then the list, and yours should be interchanged
# 2nd -> list is a keyword, try using, a different working variable
# 3rd -> you are trying to print the whole list, what the output want is like on the 1st iteration is "Hello World"