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 trialJoseph Christianson
435 PointsHow do you incorporate the string added to World? I'm thinking it's %s but this one is really odd.
See above
hellos = [
"Hello",
"Tungjatjeta",
"Grüßgott",
"Вiтаю",
"dobrý den",
"hyvää päivää",
"你好",
"早上好"
]
3 Answers
Joseph Christianson
435 PointsI see. Okay, so in trying to understand the logic of the programming language, how does Python know that's the right step? I just don't understand how a single value tells the program, okay grab these strings. Can you explain?
Haider Ali
Python Development Techdegree Graduate 24,728 PointsHi Joseph, the way you concatenate 2 or more things together in python is by simply using a +
sign.
Here is what your code should look like:
hellos = [
"Hello",
"Tungjatjeta",
"Grüßgott",
"Вiтаю",
"dobrý den",
"hyvää päivää",
"你好",
"早上好"
]
for i in hellos: #go through each string in hellos
print(i + ' World') #print the hello followed by the string ' World'
Joseph Christianson
435 PointsThanks for the speedy reply, Haider and Jason. what does the "i" serve as? As in, how does it bring each of those strings down?
Haider Ali
Python Development Techdegree Graduate 24,728 PointsSorry, I assumed you had learned about this. Each time the loop happens, it goes through the hellos list and 'i' is the current item in the list. You do not have to write 'i' as it is just the name of a variable and can be called anything. However, it is very common that programmers use i and other short names like this.
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsHi Joseph,
What code have you tried? Are you able to create the for loop that would iterate through all the hellos?