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 trialGreg Isaacson
Courses Plus Student 702 PointsWhy is my code failing?
Hi guys!:)
I think my code is right but its not passing? any ideas??
Thanks:)
hellos = [
"Hello",
"Tungjatjeta",
"Grüßgott",
"Вiтаю",
"dobrý den",
"hyvää päivää",
"你好",
"早上好"
]
str1 = "World"
for hello in hellos:
while True:
print(hellos + str1)
1 Answer
Umesh Ravji
42,386 PointsHi Greg, there are a few small issues with your code :)
1.
Make sure to include the space between the hello
and World
by adding it to the front of str1
.
2.
Remove the while
loop, it's not required in this case.
3.
Make sure to use the value of hello
(string item) for each iteration, not hellos
(which is the list that you are iterating through.
str1 = " World"
for hello in hellos:
print(hello + str1)
Greg Isaacson
Courses Plus Student 702 PointsGreg Isaacson
Courses Plus Student 702 PointsHi Umesh,
Thank you for your detailed answer.
I did what you suggested and passed the test. I understand your reasons 1 & 2. I am not sure if I understand reason no 3.
Does the challenge ask me to print each word in the list + hello OR Hello world = to the number of words in hellos???.
I think that is what was confusing me!
Thanks!:)
Umesh Ravji
42,386 PointsUmesh Ravji
42,386 PointsThe question wants you to print each word in the list +
World
. Below is what the output should look like: