In Python, you can convert a string to an integer using the int()
function. Here's an example:
string_num = "123" # Example string representing a number
integer_num = int(string_num) # Convert the string to an integer
print(integer_num) # Output: 123 (as an integer)
This will convert the string "123"
to the integer 123
.