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

Benjamin Peters
Benjamin Peters
552 Points

What is wrong with my for loop code?

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

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Honestly? Nothing is really wrong. This is an example of challenges being picky. You must follow the instructions to the letter. This means taking into consideration capitalization, punctuation, and white spaces when printing strings. Your code is printing the word + "world". This will result in the first print being "Helloworld" instead of "Hello World". Take a look at the formatting needed:

for word in hellos:
  print(word + " World")
Benjamin Peters
Benjamin Peters
552 Points

Thanks! I will give that a try and see what happens. I appreciate the help.

Benjamin Peters
Benjamin Peters
552 Points

You were right! I needed to check my capitalization and spacing. Thanks! I'll look out for that in the future.