Python Python Basics (2015) Logic in Python Loop

Sean Frye
Sean Frye
1,166 Points

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"
hellos = [
    "dobrý den",
    "hyvää päivää",
for hello in hellos:
    if hellos == "Tungjatjeta":

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.

Sean Frye
Sean Frye
1,166 Points

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
Hoessein Abd
Python Web Development Techdegree Student 13,017 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"