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 trialManny Cortez
13,475 PointsReassign the Menu Variable?
I'm currently stuck on this step. I'm not sure how to reassign menu variable. Please help! Thanks so much.
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
menu = "Our available flavors are: {}."
display_menu = ", ".join(sundaes)
1 Answer
Kieran Barker
15,028 PointsThe longer (and arguably easier to read) way is to do it 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)
Or, if you want to do it in one line, you can do this, forgoing the need for a display_menu
variable at all:
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
menu = "Our available flavors are: {}.".format(", ".join(sundaes))
Manny Cortez
13,475 PointsManny Cortez
13,475 PointsKieran, thank you so much for your thorough answers! I'm an art major trying to myself how to code, so this very foreign to me, haha. I really appreciate your help!
Kieran Barker
15,028 PointsKieran Barker
15,028 PointsYouβre welcome! It can be confusing as hell sometimes. Keep it up ?