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

Isaac Barron
Isaac Barron
7,011 Points

[SOLVED] -- What am I doing wrong here?

I understand how this format method works but its just not working for me. Not sure what I'm doing wrong

Wilson Usman
Wilson Usman
35,206 Points

Isaac Barron Can you post the format your are talking about?

Isaac Barron
Isaac Barron
7,011 Points

Challenge Task 1 of 3

I think it's time for a snack. Luckily I have a string full of types of ice cream sundaes. Unluckily, they're all in one string and the string has semi-colons in it too. Use .split() to break the available string apart on the semi-colons (;). Assign this to a new variable sundaes.

available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(';')

Challenge Task 2 of 3

Let's add a new string variable for displaying our menu items. Make a new variable named menu that's set to "Our available flavors are: {}.".

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

Challenge Task 3 of 3

Alright, let's finish making our menu. 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.

The error => Bummer! Didn't find the right series of sundaes and commas in menu.

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

Thanks! These codeChallenges are WAYYY to specific.

8 Answers

Isaac Barron
Isaac Barron
7,011 Points

I just figured it out and I was missing a period inside of my menu string.

# Incorrect
menu = 'Our available flavors are: {}'.format(', '.join(sundaes))
#                                    ^

# Correct
menu = 'Our available flavors are: {}.'.format(', '.join(sundaes))
#                                    ^
Jonathan Hughes
Jonathan Hughes
2,040 Points

I did the exact same thing, I presumed the period was just there to show the end of the string in task 2 so I removed it when inserting the ".format'".

Challenge Task 2 of 3

Let's add a new string variable for displaying our menu items. Make a new variable named menu that's set to "Our available flavors are: {}.".

menu = 'our available flavors are: {}'

it works what they put as an answer here but the explanation on the step 3 is not easy to understand :P cheers

Challenge Task 2 of 3

Let's add a new string variable for displaying our menu items. Make a new variable named menu that's set to "Our available flavors are: {}.".

menu = 'our available flavors are: {}'

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

hi all can you please tell me what i did wrong because it keeps saying "Bammer! did you use the join(',') here i my code menu = " Our available flavor are: {}." jointed_string = ","join(sundaes) menu = menu.format(','.join(sundaes)

please help

Sorry not

menu = menu.format(jointed_string)

I was stuck on this for a long time and then realised that is because of US spelling!

Yes, I should have paid attention to the request, but sometimes us non US people don't even think to write flavor instead of flavour !!

Might be worth allowing both US and non US English variations of free text so others don't sit there shaking their fists like I was, haha!

Lesson learned!