-3

i want to get the number from a string

Example:

a = '22,123 games'

Result:

result = 22123
blhsing
  • 91,368
  • 6
  • 71
  • 106
Oane
  • 49
  • 4

1 Answers1

2

First you need to find where the number is. I assume that it's before the first space, so

number = a[0 : a.find(' ')]

Then you have to remove commas:

noCommas = number.replace(',', '')

And then convert to int:

res = int(noCommas)