Assume the following statement appears in a program:
values = 'one$two$three$four'
Write a statement that splits the string, creating the following list:
['one', 'two', 'three', 'four']
PROGRAM CODE:
values = 'one$two$three$four'
result_list = values.split('$')
print(result_list)
Explanation:
split('$')
function call splits the string values
at each occurrence of the dollar sign $
, creating a list with the desired elements.OUTPUT:
['one', 'two', 'three', 'four']