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

Greg Isaacson
PLUS
Greg Isaacson
Courses Plus Student 702 Points

Not sure what is wrong?

Hi all!

I need help again..

The question is asking me to print all the names in the list hellos.

for hello in hellos: print(hellos)


This should print all the names???

To add "world" can I not add str1 to the print command print(hellos + str1)??

I tried print(hellos + "world") but that fails!!

Thanks:)

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

1 Answer

Grace Kelly
Grace Kelly
33,990 Points

Hi Greg,

you've got the right idea but you are printing out the hellos list instead of the hello element inside your for loop, you need to print the hello value. In addition to this your str1 needs a space before or else you'll get "HelloWorld" which is not what we want. This code challenge also requires a full stop at the end of the sentence. So doing the above we get something like this:

hellos = [
    "Hello",
    "Tungjatjeta",
    "Grüßgott",
    "Вiтаю",
    "dobrý den",
    "hyvää päivää",
    "你好",
    "早上好"
]

str1 = " World."
for hello in hellos:
    print(hello + str1)

Hope that helps!!