I am trying to convert the string str1 to a list of numbers so that I could sum them up. First I use the split() function to make sense of the numbers in str1, I cast the string
Using split() will not split up str1, as without the sep argument the default separator is a space ' '. Hence:
split()
str1
sep
' '
str2 == ["13,22,32,4,5"]
you need to specify that split should use a comma ','. In fact, you can combine your operations into one:
split
','
sum(map(int, str1.split(',')))