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

Shoot! This is harder than I thought.

I believe I could get this down if I spent more time practicing and taking these courses so I could remember everything, but still, something seems different about this question than what I saw on the video itself.

I understand the coding I am supposed to type, I just don't know how to get the word "World" in there to make it say "Hello World"

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

2 Answers

for hello in hellos: print("%s World" %hello)

hellos is the array with all elements, and you are iterating through it, with hello being the the single elements for each iteration. And don't forget formatting, python is very strict there.

Thank you! I got it thanks to you, yet I'm actually still confused as to way it's set up this way. You did remind me about % as I forgot I can use that as ampersand.

Hoessein Abd
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Hoessein Abd
Python Web Development Techdegree Graduate 19,107 Points

I think you misinterpreted the question a tiny bit. The list "Hello's has several 'hello' items in it in different languages. Kenneth is asking you to add the word 'World' to each item in 'Hello's.

So this should be printed.

"Hello World"

"Tungjatjeta World"

"Grüßgott World"

"Вiтаю World"

"dobrý den World"

"hyvää päivää World"

"你好 World "

"早上好 World"