I have the below code
import re
age = []
txt = ('9', "10y", "4y",'unknown')
for t in txt:
if t.isdigit() is True:
age.append(re.search(r'\d+',t).group(0))
else:
age.append('unknown')
print(age)
and I get: ['9', 'unknown', 'unknown', 'unknown']
So the 9 I get, but I also need to get the 10 in the second position, the 4 in the third and unknown for the last.
Can anyone point me in the right direction?
Thank you for your help!