Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,520 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")