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

Paul Je
Paul Je
4,435 Points

Updated version

Not sure what the correct syntax is to correct this issue? Thank you in advance!!

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


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

2 Answers

Vittorio Somaschini
Vittorio Somaschini
33,371 Points

Hi Paul.

There is an indentation problem in the last line of the code (the challenger should warn you about this).

Also, there is another small mistake: in the print statement you are missing a space: with the code you have written the 2 words will be printed together, for example hello + world will result in helloworld instead of hello world!

;)

Vittorio

Robert Esteves
Robert Esteves
1,301 Points

Hi Paul,

I agree with Vittorio.

The error is in the "for" loop. Remember that after the colon (:) you need to indent your code. Also, the print statement needs a space between Hello and "World".

Finally, you don't the parentheses around the "hello" variable in the print statement.

Hope that helps.