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 trialJothum Chitewe
7,833 Pointsfor loop
help am stuck
hellos = [
"Hello",
"Tungjatjeta",
"Grüßgott",
"Вiтаю",
"dobrý den",
"hyvää päivää",
"你好",
"早上好"
]
for hellos in list:
print(hellos)
2 Answers
Steve Hunter
57,712 PointsHi there,
You want to iterate through hellos
, so that comes after the in
. It is the list!
So, you have a list of words. You want to pull out each word in turn from that list. You use a for
loop.
for word in hellos:
This will work through all of hellos
and put each word in the word
variable. In this challenge you want to print out the word
plus " World"
. So you need to amend your print
command a little to print word + " World"
.
Something like:
for word in hellos:
print(word + " World")
I hope that helps,
Steve.
Antonio De Rose
20,885 Pointsfor hellos in list:
print(hellos)
# 1st -> in python, first comes the working variable, then the list, and yours should be interchanged
# 2nd -> list is a keyword, try using, a different working variable
# 3rd -> you are trying to print the whole list, what the output want is like on the 1st iteration is "Hello World"
Jothum Chitewe
7,833 PointsJothum Chitewe
7,833 Pointsthanks steve
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsNo problem!