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 trialSISLEY NGUYEN
1,835 PointsAlright, let's finish making our menu. Combine the sundaes list into a new variable named display_menu, where each item
Alright, let's finish making our menu. Combine the sundaes list into a new variable named display_menu, where each item in the list is rejoined together by a comma and a space (", "). Then use .format() on our existing menu variable to replace the placeholder with the new string in display_menu. If you're really brave, you can even accomplish this all on the same line where menu is currently being set
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes=available.split(';')
menu=("Our available flavors are: {}." )
display_menu.join("sundaes", "menu")
display_menu = "Our available flavors are: {}.".format(", ".join(sundaes))
8 Answers
David Hamilton
21,522 PointsYou are close, to do it one line it just needs to be on the menu variable. Below is how I did it.
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(';')
menu = ("Our available flavors are: {}." ).format(", ".join(sundaes))
Garrett Guevara
11,331 PointsHi Sisley,
The first thing we do is:
- split the available string on ";" and assign it to the variable sundaes
- then we will join that new string in the variable sundaes on ", "
- assign that new string to the variable display_menu
- then we will use the .format(display_menu) to show the correct string in the placeholder in the menu variable
Hope this helps and best of luck!
Garrett
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(';')
display_menu = ", ".join(sundaes)
menu = "Our available flavors are: {}".format(display_menu)
micram1001
33,833 Pointsavailable = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
menu ="Our available flavors are: {}.".format(", ".join(sundaes))
display_menu = menu
my answer
nathanielcusano
9,808 Pointsavailable = "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)
Gavin Schilling
37,904 PointsLOL! It will not let me do it all on one line due to Challenge 1 & 2. Guess I get an A++ for this one.
menu = "Our available flavors are: {}.".format(", ".join("banana split;hot fudge;cherry;malted;black and white").split(";"))
Stephen Hanlon
11,845 PointsI found I needed to delete this line: display_menu = ", ".join(sundaes)
Then put this part: ", ".join(sundaes) inside format.
It finally passed!! : )
With this variable and value ---> display_menu = ", ".join(sundaes) <---- still there I kept getting errors.
HIDAYATULLAH ARGHANDABI
21,058 Pointsavailable = "banana split;hot fudge;cherry;malted;black and white" sundaes = available.split(';') menu = ("Our available flavors are: {}." ).format(", ".join(sundaes))
Gabriel Reed
560 PointsIt's absolutely impossible to figure this out just based solely on the video. Can you guys seriously not stick to the content you thus far created??
David Payne
1,037 PointsAgreed especially us that is very new to Python. :)
Philip Ambrose
2,091 PointsI agree, I am becoming more and more frustrated with this course. The video content does not provide enough information to complete these quizzes.
Bo Winters
Full Stack JavaScript Techdegree Student 1,481 PointsBo Winters
Full Stack JavaScript Techdegree Student 1,481 PointsDavid,
I did everything Garrett said multiple times on my own and it never worked. I did your method and it worked. I'm just confused because in your method you never assign the variable "display_menu" - am I missing something?
David Hamilton
21,522 PointsDavid Hamilton
21,522 PointsHello Bo,
My code is showing the solution to do the last task on one line. When doing it this way you do not need to create the "display_menu" variable.
The code in Garrett's answer should work. Below is the code I used when doing the solution with the "display_menu" variable.