1>>> import re
2>>> string1 = "498results should get"
3>>> int(re.search(r'\d+', string1).group())
4498
1# Use the function int() to turn a string into an integer
2string = '123'
3integer = int(string)
4integer
5# Output:
6# 123
1# this is a string
2a = "12345"
3# use int() to convert to integer
4b = int(a)
5
6# if string cannot be converted to integer,
7a = "This cannot be converted to an integer"
8b = int(a) # the interpreter raises ValueError
1#INTEGERS
2# Use the class int() to turn a string into a integer
3s = "120"
4s = int(s)
5print(s+1)
6#121
7#FLOATS
8# Use the class float() to turn a string into a float
9s="2.5"
10s = float(s)
11print(s*2)
12#5.0