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

vvsr sashank
vvsr sashank
1,393 Points

what to do?

hellos

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

2 Answers

Thomas Fildes
Thomas Fildes
22,687 Points

Hi vvsr,

Basically the challenge asks you to create a for loop to pass through each items in the list and print it out before the word 'World'. This is achieved with the code below:

for hello in hellos:
    print(hello + " World")

you use the print function inside the loop to execute each item with a plus sign to add the string World at the end with a space before it so it doesn't stick the two words together. Hope this helps.

Happy Coding!!!

let me know if you need an explanation of this

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