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

Still can not get it .

Tried it 100 times but do not get the proper answer .It tells "oops! it looks like task 1 is no longer passed"

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

2 Answers

You are close!

It seems to me you are mixing some stuff up.

Try this:

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

How it works:

  1. The challenge made us a variable called available which is a string of available flavors separated by semicolons.
  2. We make a variable called sundaes which is a list of the available flavors. We split by the semicolon to do this.
  3. Then we join the sundaes list by a comma AND a space, not just a comma. We set that value to menu. If we didn't had the space the menu variable would look like this (look at Figure 2 to see)
  4. Finally we add the text "Our available flavors are: " to the beginning of the menu variable and set that value to the display_menu variable.

The final output will look like Figure 1.

Figure 1:

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

Figure 2:

banana split,hot fudge,cherry,malted,black and white

As you see in Figure 2, there's no extra spaces after each comma. You have to explicitly say to add a space in the code.

I hope this helps.

Good luck :smile:

~Alex

Tagging Kenneth Love

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

Alexander Davison I'm not sure why you're tagging me. The grader is working correctly. I don't need to be tagged to every post :)

At last I am able to do it. thank you for your help....

Oh... Sorry. I thought Rezwan was still having issues with my code but I was pretty sure my code was correct so that's why I tagged you :smile:

still error now it says it looks like Task 2 is no longer passing