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 trialConary Beckford
Full Stack JavaScript Techdegree Student 5,046 Pointsclarification on loops
How do I add a word to a list using loops?
hellos = [
"Hello",
"Tungjatjeta",
"Grüßgott",
"Вiтаю",
"dobrý den",
"hyvää päivää",
"你好",
"早上好"
] for hellos in hellos:
print("hellosWorld")
5 Answers
Craig Dennis
Treehouse TeacherYour line of code
print("Hello " + "World")
Won't that always say "Hello World"? I think you want to use the variable hello
you are introducing in your for loop, right?
Let me know if that hint doesn't do the trick ;)
Conary Beckford
Full Stack JavaScript Techdegree Student 5,046 PointsBummer! Didn't find 'Tungjatjeta World' in your output. Restart
Conary Beckford
Full Stack JavaScript Techdegree Student 5,046 PointsNot clear on what im doing wrong.
Conary Beckford
Full Stack JavaScript Techdegree Student 5,046 Points'''hellos = [ "Hello", "Tungjatjeta", "Grüßgott", "Вiтаю", "dobrý den", "hyvää päivää", "你好", "早上好" ] for hellos in hellos: print("Hello " + "World")'''
Adam N
70,280 PointsWrap your code with 3 backticks (```) on the line before and after.
Adam N
70,280 PointsA few things:
- Need to start the loop completely under the list
- Each time through the loop you need to concatenate the string "World" to the current item the loop is on
- Don't forget the space between the two words
Let me know if this helps here
Conary Beckford
Full Stack JavaScript Techdegree Student 5,046 Pointshellos = [
"Hello",
"Tungjatjeta",
"Grüßgott",
"Вiтаю",
"dobrý den",
"hyvää päivää",
"你好",
"早上好"
]
for hellos in hellos:
print("Hello " + "World")
Adam N
70,280 PointsPlease paste the code w/ markdown formatting
Conary Beckford
Full Stack JavaScript Techdegree Student 5,046 PointsConary Beckford
Full Stack JavaScript Techdegree Student 5,046 PointsThank you. It worked.