Here is my program:
import re
string = "I have 56 apples, Tom has 34 apples, Mary has 222 apples"
apple = re.findall(r'\d{1,100}', string)
print (apple)
And the outcome is:
['56', '34', '222']
I want to name the three numbers above so that I can do some calculation. I also want to name the first outcome a, second one b, third one c. And then calculate a+b or a+c, something like that. Could anyone tell me how to do it.
If re.findall can't solve my case here, is there another way to achieve this goal?
apple[0] + apple[1]?string, that will shadow the builtin library (import string). Call your strings, or whatever.