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 trialAndy Hughes
10,049 PointsWhy won't python splitting and joining challenge work
I am on step three of the Python "splitting and joining" challenge and I've checked my code in Python Fiddle and it works fine. However, when I post the code into the challenge, it tells me "it didn't find the right series of sundaes or commas and spaces". I've tried rewriting the code a few times in different ways and I've also done it in one simpler line of code, but nothing works.
Also, the Python preview for code challenges never seems to work. I wonder if this is related. Anyways, if anyone can see something I'm doing wrong, that would be useful to know.
Thanks
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
menu = "Our available flavors are: {}."
display_menu = ", ".join(sundaes)
display_menu = menu.format(display_menu)
print(display_menu)
2 Answers
andren
28,558 PointsThe challenge does not require you to print anything out. Your code is nearly correct, but the challenge asks that you replace the contents of the menu variable with the formatted menu. You are replacing the display_menu with the formatted menu.
So changing that line like this:
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
menu = "Our available flavors are: {}."
display_menu = ", ".join(sundaes)
menu = menu.format(display_menu)
Will allow you to pass, similarly for the shortened one line version you should also set the menu variable like this:
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
menu = "Our available flavors are: {}.".format(", ".join(sundaes))
That solution will also allow you to pass the challenge.
Andy Hughes
10,049 PointsAh, as soon as I read your first paragraph the lightbulb went on. I guess it was a case of can't the "wood for trees" lol! Thank you, passed now.