turn cha to int in python code example
Example 1: python string to int
# Use the function int() to turn a string into an integer
string = '123'
integer = int(string)
integer
# Output:
# 123
Example 2: python cast to int
x = int(1) # x will be 1
y = int(2.8) # y will be 2
z = int("3") # z will be 3