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 trialNicholas Anstis
2,095 PointsI need you to write a for loop that goes through each of the words in hellos and prints each word plus the word "World".
I don't know what do to do. :P
hellos = [
"Hello",
"Tungjatjeta",
"Grüßgott",
"Вiтаю",
"dobrý den",
"hyvää päivää",
"你好",
"早上好"
]
for hellos in world:
print(hellos + world)
world = world
3 Answers
Haider Ali
Python Development Techdegree Graduate 24,728 PointsHi Nicholas, you have the basic idea right, only there are a couple of places where you are going wrong. Firstly, you should be looping through the list hellos
. For each greeting in hellos you should print that greeting plus " World"
. You have forgotten your quote marks around 'world' which makes the challenge think you are attempting to print a variable called world
whereas this is not the case. Lastly, the challenge doesn't ask you to define a variable called world so if you leave that out your code should look like this;
for greeting in hellos:
print(greeting + " World")
If you have any further questions please leave a comment :)
Thanks,
Haider
Omar Richardson
3,452 PointsDoes anyone see an issue with my code?
I am getting an error when trying to validate the code
hellos = [
"Hello",
"Tungjatjeta",
"Grüßgott",
"Вiтаю",
"dobrý den",
"hyvää päivää",
"你好",
"早上好"
]
for hello in hellos:
print(hello + "World")
Haider Ali
Python Development Techdegree Graduate 24,728 PointsAt the beginning of the "World"
string you need a space otherwise the words will be right next to each other like this:
HelloWorld
Ronnie Jimenez
Courses Plus Student 2,345 PointsThis code worked for me.
hellos = [
"Hello",
"Tungjatjeta",
"Grüßgott",
"Вiтаю",
"dobrý den",
"hyvää päivää",
"你好",
"早上好"
]
for hello in hellos:
print(hello + " World")
Nicholas Anstis
2,095 PointsNicholas Anstis
2,095 PointsThank you! That was of great help :D