-3

i want to get the number from a string

Example:

a = '22,123 games'

Result:

result = 22123
1
  • where is your code ? Commented Feb 23, 2019 at 5:10

1 Answer 1

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)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.