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

Question down below, any help please?

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".

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

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

1 Answer

28,558 Points

Your code is pretty close but there are two issues.

The first is that hellos is the name of the list itself, while hello is the name of the item that is pulled out of the list. Because of that you have to print out hello not hellos.

The second issue is that when you concatenate strings together they are glued to each other without any spacing added. So you would end up with words that run together like HelloWorld instead of Hello World. To fix that you simply need to manually insert a space in order to compensate.

Fixing both of those issues produces this loop:

for hello in hellos:
    print (hello + " World") # Changed "hellos" to "hello" and added space in front of "World"

Which will pass the challenge.

thanks alot!