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

Abhishek Kumar
Abhishek Kumar
713 Points

Can you point out, where is the error in last line of code? It seems fine to me.

Can you point out the error in last line of code in banana.py? It seems fine to me.

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

the last line should read display_menu = menu.format(", ").join(sundaes)

Abhishek Kumar
Abhishek Kumar
713 Points

Yodh Garfias that is also giving the same error.

1 Answer

jonlunsford
jonlunsford
10,891 Points

Abhishek:

Here is how I solved part 3 (last two lines). I assigned the joined string back to display_menu. Then I reassigned menu, making it equal to the formatted menu string. Such as:

available = ...
sundaes = ...
menu = "Our available flavors are {}."
display_menu = ', '.join(sundaes)
menu = menu.format(display_menu)

Another way this could be done using one line, as the challenge suggests:

available = ...
sundaes = ...
menu = "Our available flavors are {}."
menu = menu.format(', '.join(sundaes))