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 trial

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

Bryony Stewart
Bryony 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.

banana.py
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(', ')
Torsten Lundahl
Torsten Lundahl
2,570 Points

You 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.

Bryony Stewart
Bryony Stewart
1,230 Points

Thanks 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

Try this:

banana.py
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:

  1. 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 called sundaes.
  2. We join 'sundaes' by the ', ' string and store that value into a variable called menu.
  3. We format menu into the message the code challenge gave us and save that in a variable called display_menu, then...
  4. Ta-da! Code challenge complete :)

I hope this helps. :smile:

Good luck! ~Alex