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 trialAlma Cuevas
2,703 Pointsfor words in hellos: print(hellos + 'World') Bummer! can only concatenate list (not "str") to list
Why does it say that?
hellos = [
"Hello",
"Tungjatjeta",
"Grüßgott",
"Вiтаю",
"dobrý den",
"hyvää päivää",
"你好",
"早上好"
]
for words in hellos:
print(hellos + 'World')
2 Answers
AJ Salmon
5,675 PointsThe error is being raised because you're trying to concatenate the list hellos
with the string "World"
. Instead of printing hellos + " World" you need to print words + " World". When you use a for loop, the first name you give it (example: 'x' in for x in y
) represents each item in the iterable you give it, which is the second object that comes after the 'in'. Also, make sure you include an extra space at the start of your string! You want it to print "Hello World" not "HelloWorld".
Hirenkumar Patel
Courses Plus Student 9,464 PointsPut words instead hellos and add space Before World See as under
for words in hellos: ti = words + " World" print(ti)