Python Python Basics (2015) Python Data Types Use .split() and .join()

Teresa Grall
Teresa Grall
1,112 Points

Isn't sundaes a list? Why isn't my code passing here?

Here's what I've got:

available = "banana split;hot fudge;cherry;malted;black and white" sundaes = available.split(";") menu = "Our available flavors are: {}.".format(", ".join(sundaes)) display menu = sundaes.join(", ")

Why isn't this right? BTW, I've done this quiz three times now. I've guessed the right answer twice, but since the screen whisks away after you get it right, I couldn't study it to see what I did right. Now I'm trying to get this figured out once and for all.

banana.py
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
menu = "Our available flavors are: {}.".format(", ".join(sundaes))
display menu = sundaes.join(", ")

4 Answers

Teresa Grall
Teresa Grall
1,112 Points

Putting this answer here in case someone else is looking it up. I finally solved it and managed to copy my code before it disappeared. Turns out this is the correct code: available = "banana split;hot fudge;cherry;malted;black and white" sundaes = available.split(";") menu = "Our available flavors are: {}.".format(", ".join(sundaes)) display_menu = ", ".join(sundaes)

Apparently I had the display_menu variable part backwards (I had sundaes.join(", ") and it should have been ", ".join(sundaes), and then my code was actually correct on the third line. I've got to say, this was frustrating and confusing as hell. I've been beating my head against the wall screwing around with the third line when it was the fourth line I had wrong. The error message gave me no indication where my mistake was, it just kept telling me to use ", ".join(sundaes), and it was driving me crazy that I already had that on the third line.

Antonio De Rose
Antonio De Rose
20,866 Points
display menu = sundaes.join(", ")

can you take off this line completely out and run it, as I mentioned already above and run, should work.

The error message on that code challenge gives you the answer: You want ", ".join(sundaes)

P.s.: Your var display menu is missing an underscore.

Teresa Grall
Teresa Grall
1,112 Points

Yeah, I've read that error message dozens of times now. That doesn't help me, especially since I already have ", ".join(sundaes) on the third line. As for the missing underscore, yeah, I know about that, I had it right the other zillion times I tried this exercise but it didn't pass.

The code challenge is made of 3 tasks. I used your own code, line by line, to progress through the first 2 tasks successfully, so when I reached the last phase I knew which line the error message was referring to. I commented on the missing underscore because it's what you are sharing publicly, I have no idea what you have tried previously - moreover, if you "know about that" why not correct it in the first place before writing your question? Anyway, if you are going to get this frustrated every time you encounter a bug, you are in for a bad time. Take it easy and happy coding!

Antonio De Rose
Antonio De Rose
20,866 Points
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
menu = "Our available flavors are: {}.".format(", ".join(sundaes))
display menu = sundaes.join(", ") #this line is redundant, as you have done what is needed, in all above 3 steps
#so you should take that line out, btw, in any case, you cant have variable name in 2 words like display menu