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