I would extract all the numbers contained in a string. Which is the better suited for the purpose, regular expressions or the isdigit()
method?
Example:
line2 = "hello 12 hi 89"
temp1 = re.findall(r'\d+', line2) # through regular expression
res2 = list(map(int, temp1))
print(res2)
Hi ,
you can search all the integers in the string through digit by using findall expression .
In the second step create a list res2 and add the digits found in string to this list
hope this helps
Regards, Diwakar Sharma