0
How to extract a number in the form of integer from a string
5 Respostas
+ 7
It's clear what you mean, but it would be a good idea if you could provide a sample string, that shows the input. Is it just one number or are there multiple occurrances or other numbers? Should they all be treated? Thanks!
+ 6
txt = 'my age is 34'
age = int(''.join([i for i in txt if i.isdigit()]))
print(age)
+ 1
Like for example
str=input('my age is 34')
So i want to have that 34 as an integer
Thanks a lot
+ 1
Thanks a lot bro
Really helped
0
no_dup = list(set([i for i in 'f1e10zp' if i.isdigit()]))
dup = [i for i in 'f1e10zp' if i.isdigit()]