Python Python Basics (2015) Logic in Python Loop

Maryan Tuzyak
Maryan Tuzyak
1,495 Points

python for loop , looping through all greetings and adding world to list

I need you to write a for loop that goes through each of the words in hellos and prints each word plus the word "World". So, for example, the first iteration would print "Hello World". this is the question asked in challenge and on preview i added 'hello world' but it says it cant find tungjatjeta when it's actually there

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

hellos.append("Hello World")

for hello in hellos:
    print(hello)
Jeremy Hill
Jeremy Hill
20,424 Points

I don't think you need to append or remove anything from the list. You just need to iterate through the list printing each item in the list with a space and formatting it with "world". I can give you the code if I need to but just try doing it with what I gave you first.

Maryan Tuzyak
Maryan Tuzyak
1,495 Points

yea but this gets hello world in there but it doesn't read it at the end of the list for some reason. what code did you use to format it ?

7 Answers

Jeremy Hill
Jeremy Hill
20,424 Points

My internet is poor where I'm located right now so I can't run the code so I'm going to tell you what I think it is:

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

for hello in hellos:
    print("{} World".format(hello))
Jeremy Hill
Jeremy Hill
20,424 Points

I just ran the code I gave you and it passed the challenge.

Jeremy Hill
Jeremy Hill
20,424 Points
hellos = [
    "Hello",
    "Tungjatjeta",
    "Grüßgott",
    "Вiтаю",
    "dobrý den",
    "hyvää päivää",
    "你好",
    "早上好"
]
# REMOVE THIS ---> hellos.remove("Hello")

# REMOVE THIS --->hellos.append("Hello World")

for hello in hellos:
    print("{} World".format(hello)) #Changed this line
Thomas Souza
Thomas Souza
7,391 Points

for hellos in hellos: print("{} World".format(hellos))

Jeremy Hill
Jeremy Hill
20,424 Points

I answered in the comment.

Maryan Tuzyak
Maryan Tuzyak
1,495 Points

hellos = ["Hello{}","Tungjatjeta","Grüßgott","Вiтаю","dobrý den","hyvää päivää","你好","早上好"] hellos.format('world') for i in range(1): print(hellos)

Maryan Tuzyak
Maryan Tuzyak
1,495 Points

this printed out hello world 10 times, i'm still trying to figure it out thanks for the try

Maryan Tuzyak
Maryan Tuzyak
1,495 Points

thanks a lot bro, it worked i guess the spacing must of been off when i was putting it in.