Python Python Basics (2015) Logic in Python Loop

Nicholas Blocher
Nicholas Blocher
5,848 Points

The following code works, I checked it in python on my computer but for some reason I can't continue with the challenge?

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

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

1 Answer

Alex Koumparos
MOD
Alex Koumparos
Python Web Development Treehouse Moderator 33,475 Points

Hi Nicholas,

Not sure how the code is working on your computer. As written, your code will never print anything (and if it did, it would print the wrong thing). This line:

greeting + " World"

has no assignment, so you are never adding " World" to the greeting variable. Then you have continue which ends the current cycle of the loop and starts the next cycle before your print statement which means that your print statement will never be called.