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

Enzie Riddle
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Enzie Riddle
Front End Web Development Techdegree Graduate 19,278 Points

If Loops

Here's the question:

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

What am I doing wrong? I added the lines 11 and 12.

Thanks!

loop.py
hellos = [
    "Hello",
    "Tungjatjeta",
    "Grüßgott",
    "Вiтаю",
    "dobrý den",
    "hyvää päivää",
    "你好",
    "早上好"
]
for hello in hellos:
    print(hellos + 'World')

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hey Enzie,

You're really close, there are just 2 things.

  1. Remember that the temporary variable (in this case 'hello with no 's') is what holds the value in each iteration of the loop. This is what needs to be printed out. hellos with an "s" is what the loop is iterating through.

  2. The sentence being printed needs to match the instructions exactly. Right now yours will print "HelloWorld" with no space. You just need to add a space... easiest way here would be after the " and before the W ... " World"

Other than that, all's good. :)

Keep Coding! :dizzy: