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

Help, I don't know what to do with this one, how do I do it, and can you explain for me?

I don't understand the question, can you help? please explain how to do this.

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

1 Answer

Patrick Rice
Patrick Rice
11,017 Points

You are close - you don't need the "if" statement. In the for loop, you just need to call hello in the print, not hellos. hello will be replaced with each item in the list as the for loop goes through each item (iterates). Then, add (+) World. Make sure to include a space within the string "World" so the first iteration doesn't print "HelloWorld". It would look like this: print(hello + " World")