For a number that is 32,146 ...how do I find only 146? Is this able to be done?
findnum = '32,146'
return findnum
For a number that is 32,146 ...how do I find only 146? Is this able to be done?
findnum = '32,146'
return findnum
Work with split
>>> findnum = '32,146'
>>> findnum.split(',')
['32', '146']
If you want the number you can do:
# get number by ignoring commas
number = int(findnum.replace(',',''))
# get last three digits
last_three = number % 1000
This will result in 146
(int) and not '146'
(string)
Example:
>>> findnum = '32,146'
>>> number = int(findnum.replace(',',''))
>>> number % 1000
146
Since its a string and not a number:
Can use slicing after the ',' to the end:
s[s.index(',')+1:]