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()

Getting error message "Didn't find the right series of sundaes and commas in `menu`.", yet my code works in the shell

So this is the code I put into shell:

available = "banana split;hot fudge;cherry;malted;black and white"

sundaes = available.split(";")

menu = "Our available flavors are: {}"

", ".join(sundaes)

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

//I do this because simply using the .join() command doesn't seem to save the edit to the variable.

This results in the following string:

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

Is that not correct? Yet any time I submit this I'm told the right series of sundaes and commas are not found despite previous tasks passing without issue.

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

2 Answers

Daniel Gauthier
Daniel Gauthier
15,000 Points

Hey Mark,

Line four is where you're going wrong. Try adding the .format to the end of the third line.

The following code passes:

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

Good luck!

Oh, I see. Thanks!

I was under the impression that I could use menu.format() to edit the variable, without the need to use 'menu ='

Chris Freeman
Chris Freeman
Treehouse Moderator 68,454 Points

Or be sure to reassign menu in the last line:

menu = menu.format(", ".join(sundaes))
Daniel Gauthier
Daniel Gauthier
15,000 Points

Hey Mark,

You can definitely add menu.format() after the fact, but the way listed above keeps your code as short as possible and keeps you from having to add additional lines.

Good luck!