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 trialzaki azizi
421 Pointshow can I solve this problem ? please help me.
I can not solve this problem
hellos = [
"Hello",
"Tungjatjeta",
"Grüßgott",
"Вiтаю",
"dobrý den",
"hyvää päivää",
"你好",
"早上好"
]
for words in hellos:
print(hellos + [' World'])
2 Answers
prateekparekh
12,895 PointsBreak 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
421 PointsThank you my Friend