python number in string code example
Example 1: how to get a number from a string in python
string = "I am 14 years old"
for i in string.split():
if i.isdigit():
print(i)
print()
Example 2: python string to int
print(int("12"))
string = "I am 14 years old"
for i in string.split():
if i.isdigit():
print(i)
print()
print(int("12"))