7 ответов
+ 13
Google : RegEx.
#this thing is really overpowered...
+ 7
x = "123abc"
y = list(filter(lambda x: x.isdigit(), x))
print( "".join(y) )
+ 4
this will work!
x = '123abc'
#every thing in printable will be printed only
printable = '1234567890'
for ch in x:
if ch not in printable:
x = x.replace(ch, "")
print(x)
+ 4
x='123abc'
print(*[i for i in x if i.isdigit()],sep='')
+ 3
Nice answer
@Fred
+ 3
Using the isdigit() method.
for i in X:
if i.isdigit ():
print (i)
+ 2
@fred,is it(ur answer )python?