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

In this assignment, I get the required output in python, but your quiz doesn't accept it.

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

display_menu = menu.format( ", ".join(sundaes))

display_menu 'Our available flavors are: banana split, hot fudge, cherry, malted, black and white.'

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

4 Answers

Robert Schaap
Robert Schaap
19,834 Points

Though it's the same thing, the challenge is asking you to set display menu first, and then on a separate line re-assign menu. Like so:

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)

Of course you could also just add .format to the line where you're declaring menu for a nice one liner :)

Thanks.:)

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 58,991 Points

The challenge is looking for the updated menu. You can use something like

menu = menu.format(....)

Post back if you need more help. Good luck!!!

Antonio De Rose
Antonio De Rose
20,860 Points
#yes it will not, am glad, that you are trying in both ways, that you have something like a source truth, to
#check against one another
#the reason it is not giving, is the questions, are really picky, and strict, that you do what it asks, regardless
#of the outcome
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(';')
menu = "Our available flavors are: {}."
display_menu = menu.format( ", ".join(sundaes))# issue is here, where the question, asks to reassign to the menu variable

# you've done more that great, with what is needed, to check against a python env

I submitted the following and it seemed to work - I agree it was a bit ambiguous either way as to what we were expected to do with the comment about being able to 'do the whole thing on one line'... especially considering that by adding

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

I suppose in a practical sense it makes it so that we will get the same answer, regardless of if we reference menu or display_menu