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

How do i get "World" to print after each word?

Could someone please complete the code for me. Thanks

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

1 Answer

Daniel Gauthier
Daniel Gauthier
15,000 Points

Hey Rakshith,

Remember that the concatenation operator for python is the + sign and the rest will fall into place. Also, for this particular challenge, it's easy to forget to add a space after the opening quotation mark containing the world World, which would also cause the code to fail.

The following code will pass:

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

for word in hellos:
    print (word + " World")

Good luck with the course!

thanks a lot for your response. Got it!