I have a string: lst = 'sbs1.23444nroen'
im using lst2 = ''.join(filter(str.isdigit, lst)) to remove all the letters so the result is: lst2 = '123444'
is there any way to include the "." so that the result would be ‘1.23444’ without the letters but keeping the dot?
>Solution :
A more friendly to the eye solution and extendable if you want to include more characters.
s = 'sbs1.23444nroen'
toKeep = set('0123456789.')
s = ''.join(ch for ch in s if ch in toKeep)
print(s)