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

Krauser Huang
PLUS
Krauser Huang
Courses Plus Student 313 Points

I'm stuck with for loop function Orz...

I know the task should perform as "Hello World" "Tungjatjeta World" "Grüßgott World"...etc

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

my logic is to use list 0 in hellos and add with "World" then remove [0] so I can use the next hellos list, though I'm not sure whether it's right Orz...

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

for word in hellos:
    print("{} " + "World".format(hellos[0])
          hellos.remove[0]
Akhil Purohit
Akhil Purohit
Courses Plus Student 581 Points

Why complicate it bud. just on your for loop, you are basically defining the variable word to go through the list hellos. so in the next argument, you need to add the same variable with the string "World" so try replacing hellos with word. that should do it.

Seth Kroger
Seth Kroger
56,413 Points

Akhil's response is definitely on the right track but I'd like to pose a rhetorical question: given the rules of operator precedence would the string concatenation happen before or after calling format()?