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 trialPratham Patel
4,976 PointsCan I have some help with this code challenge
Could some give me an answer
hellos = [
"Hello",
"Tungjatjeta",
"Grüßgott",
"Вiтаю",
"dobrý den",
"hyvää päivää",
"你好",
"早上好"
]
2 Answers
Mike Wagner
23,559 PointsA for loop for this challenge will look a bit like
for hello in hellos:
and will look at each individual entry in the list of hellos
. The code you put inside the loop will be run against each individual entry of hello
that is contained in the list hellos
from beginning to end. Knowing this, we can take the hello
and plug it into a string, either by concatenating as hello + " World"
or by using Pythons handy .format()
function in a string "{} World".format(hello)
which we would toss into the print()
function also nested inside the loop, thereby satisfying the Challenge condition by printing the following (supposing we were running it in a console):
Hello World
Tungjatjeta World
Grüßgott World
Вiтаю World
dobrý den World
hyvää päivää World
你好 World
早上好 World
Zack Mowrer
Full Stack JavaScript Techdegree Graduate 62,350 Pointsfor hello in hellos:
print("{} World".format(hello))