I am trying to create a function which allows me to have a
dictionary like this :{'Apple': 7,'Pearl: 5, 'strawberry': 3}
using this string: "Apple,2,5;Pearl,3,2;Strawberry,1,2;"
.
I want to use the numbers on the string as an integer and do the addition process to be the result. However I was trying to split the string into pieces so I can make it an integer
def cal(Fruitsamount):
Fruitsamount.split(";")
dict1 = {Fruitsamount[0:5]: Fruitsamount[5:8]}
return dict1
print(cal("Apple,2,5;Pearl,3,2;Strawberry,1,2;"))
I would like to know how can I transform part of the numbers on the string into integers so I can do the addition process