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 trialBryony Stewart
1,230 Points(banana,py,Task 3) having trouble passing this one, and I am ending up confused
I am getting very mixed up on this task and not sure how to get a pass.
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
menu = "Our available flavors are: {}.".format(display_menu
available.split(";") = display_menu
display_menu.split(', ')
Bryony Stewart
1,230 PointsThanks for your help Torsten Γsterlund, I am forgetting to declared in most of my coding. I am really passionate about learning to write code at all levels, but I am worried about falling short and not being able to progress.
1 Answer
Alexander Davison
65,469 PointsTry this:
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
display_menu = "Our available flavors are: {}.".format(', '.join(display_menu))
I'll explain step-by-step:
- We split the
available
variable by semicolons (this doesn't change the variable; it just returns the value) and store that value to a variable calledsundaes
. - We join 'sundaes' by the ', ' string and store that value into a variable called
menu
. - We format
menu
into the message the code challenge gave us and save that in a variable calleddisplay_menu
, then... - Ta-da! Code challenge complete :)
I hope this helps.
Good luck! ~Alex
Torsten Lundahl
2,570 PointsTorsten Lundahl
2,570 PointsYou are formatting menu with display_menu, before the variable has even been declared. What you want to do is to join the values inside sundaes using the join method, and assign the string to display_menu. After that you can format menu using display_menu.