How to Convert String to Int in Python
Posted on: February 22, 2021 by Ariessa Norramli
In this article, you will learn how to convert string to int in Python.
Let’s say you have an integer represented as a string.
# An integer variable named 'a' with value "12345"
a = "12345"
In order to convert string to int, you can use the int()
method.
# An integer variable named 'a' with value "12345"
a = "12345"
print(int(a))
# => 12345
Note: The int()
method functions by converting the supplied value into an integer.
Share on social media
//