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!

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

Why is the loop not finding all strings in list?

I am attempting to figure out why the loop is not finding all the strings in the hellos list. Also, how would I add the "world" to each string in hellos?

for word in hellos: print(word) + "world" ?

I realize that it is in correct.

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

for word in hellos: 

1 Answer

28,554 Points

Your loop is correct, you are just missing adding the word "World" to them. And your incorrect example is actually far closer to correct than you probably realize.

You do in fact just add the word variable to a string with " World" in it (a space is needed at the start to avoid having the words run together). But you do this inside the print statement, you don't have the + outside it.

So the loop is meant to look like this:

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