This question already has an answer here:
Newbie here, been searching the net for hours for an answer.
string = "44-23+44*4522" # string could be longer
How do I make it a list, so the output is:
[44, 23, 44, 4522]
This question already has an answer here:
Newbie here, been searching the net for hours for an answer.
string = "44-23+44*4522" # string could be longer
How do I make it a list, so the output is:
[44, 23, 44, 4522]
Using the regular expressions as suggested by AChampion, you can do the following.
The r'' signifies raw text, the '\d' find a decimal character and the + signifies 1 or more occurrences. If you expect floating points in your string that you don't want to be separated, you might what to bracket with a period '.'.
Here you have your made up function, explained and detailed.
Since you're a newbie, this is a very simple approach so it can be easily understood.