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

Amani Alm
Amani Alm
287 Points

stuck in, Use .split() to break the available string Task

For Task # 1 in splinting and Joining, I answered the following; available = "banana split;hot fudge;cherry;malted;black and white" "banana split;hot fudge;cherry;malted;black and white" .split(";") Sundaes= ['banana split', 'hot fudge', 'cherry', 'malted', 'black and white']

I am not sure I get the question. I thought I understood "splitting & joining" but for some reason, I can't pass this task. Help please!

banana.py
available = "banana split;hot fudge;cherry;malted;black and white"
"banana split;hot fudge;cherry;malted;black and white" .split(";")
Sundaes= ['banana split', 'hot fudge', 'cherry', 'malted', 'black and white']

1 Answer

Hi there,

Use the split method using dot notation on the available list. Pass in the ';' as the argument for .split(). Assign that into sundaes.

You've got most of that in your code but you've typed a lot of sundaes which are contained in available. So use that, rather than creating new strings.

Steve.

I am completely lost on how to assign the split list to sundaes!

Hi there,

Create the variable sundaes, follow that with an equals sign and after the equals sign, call the split() method on available using dot notation and put the semicolon in the parentheses surrounded by inverted commas.

Like this:

sundaes = available.split(';')

Steve.