Python Python Basics (2015) Logic in Python Loop

zaki azizi
zaki azizi
421 Points

how can I solve this problem ? please help me.

I can not solve this problem
hellos = [
    "dobrý den",
    "hyvää päivää",
for words in hellos:
    print(hellos + [' World'])

2 Answers

Break the problem down into smaller steps.

So, before trying to print all the different ways you can print "Hello world" based on all the different strings that are part of the hellos list, try to print just one way without the loop

hellos = 'Hello'
print('{} World'.format(hellos))

{} is the placeholder that will be replaced by whatever you provide inside the format() method

Now, if you have to go through the list, you need to get one item in the list at a time so that your output looks as below: Hello World Tungjatjeta World Grüßgott World

and so on.

One way to do this is shown below where the for loop runs repeated with different values of hellos list assigned to word for word in hellos: print('{} World'.format(word))

Does that make sense?

zaki azizi
zaki azizi
421 Points

Thank you my Friend