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 trial

Python Python Basics (2015) Logic in Python Loop

Pratham Patel
Pratham Patel
4,976 Points

Can I have some help with this code challenge

Could some give me an answer

hellos = [
    "dobrý den",
    "hyvää päivää",

2 Answers

A 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
for hello in hellos:
    print("{} World".format(hello))