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

Linh Tran
Linh Tran
177 Points

Please explain the request:Use that string with a .format() on our existing menu variable and replace the current value?

I don't understand this question of code challenge: Challenge Task 3 of 3 It means i need to create a new menu, right?

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

2 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

You are so very close. In your join, a SPACE is needed after the comma:

available = "banana split;hot fudge;cherry;malted;black and white"
sundaes=available.split(";")
# ", ".join(sundaes)  # <-- line not needed
# new_string="Menu includes:"+", ".join(sundaes))  # <-- line not needed
menu="Our available flavors are: {}".format(", ".join(sundaes))  # <-- added space
# menu=menu.format(new_string)  # <-- line not needed
Scott Wysocki
Scott Wysocki
2,222 Points

Hi, Chris.

The solution your provided isn't working for me. Here is the question asked in this task in full:

Combine the sundaes list into a new string, joining them with a comma and a space (", "). Use that string with a .format() on our existing 'menu' variable and replace the current value of 'menu'.

When I attempt to change the value of 'menu' as such:

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

I am told that there wasn't the right series of sundaes and commas in "menu".

I noticed that when I use the code I just entered above, the string I'd get from ", ".join(sundaes) turns back into a list.

Any suggestions? Thanks

Linh Tran
Linh Tran
177 Points

Thanks for helping, Chris. I get the point now.