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 trialMaryan Tuzyak
1,495 Pointspython 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
hellos = [
"Hello",
"Tungjatjeta",
"Grüßgott",
"Вiтаю",
"dobrý den",
"hyvää päivää",
"你好",
"早上好"
]
hellos.remove("Hello")
hellos.append("Hello World")
for hello in hellos:
print(hello)
Maryan Tuzyak
1,495 Pointsyea 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
29,567 PointsMy 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
29,567 PointsI just ran the code I gave you and it passed the challenge.
Jeremy Hill
29,567 Pointshellos = [
"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
7,943 Pointsfor hellos in hellos: print("{} World".format(hellos))
Jeremy Hill
29,567 PointsI answered in the comment.
Maryan Tuzyak
1,495 Pointshellos = ["Hello{}","Tungjatjeta","Grüßgott","Вiтаю","dobrý den","hyvää päivää","你好","早上好"] hellos.format('world') for i in range(1): print(hellos)
Maryan Tuzyak
1,495 Pointsthis printed out hello world 10 times, i'm still trying to figure it out thanks for the try
Maryan Tuzyak
1,495 Pointsthanks a lot bro, it worked i guess the spacing must of been off when i was putting it in.
Jeremy Hill
29,567 PointsJeremy Hill
29,567 PointsI 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.