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

John Frauenhoffer
John Frauenhoffer
2,008 Points

Problem with multiple hellos and adding 'World' loop

Hello guys,

I was wondering if you could look at my code and help me understand what I'm doing syntax wise in my 'for' loop that is messing this up. Thanks

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

In your line: hello in hellos the keyword 'hello' is acting as a single placeholder for the loop; the keyword 'hellos' is the entity being looped. Everything in the parenthesis is being printed and I noticed that you have "+ 'World' outside of your parenthesis. So in short, you need to print each individual item in the list 'hellos' by using the keyword 'hello' in your print statement and make sure that your "+ 'World'" is inside of your parenthesis in your print statement.

Does that make sense?

1 Answer

Per Karlsson
Per Karlsson
12,683 Points

Hey John

You need to convert the hello to a string, try something like this instead.

for hello in hellos:
    print(str(hello) + " World")

Regards, Per