How to convert a string into an int in Python?

You can convert a numeric string into an integer using int() method. The string must only contain numeric values without any additional characters or you will get a conversion error “ValueError: invalid literal for int() with base 10“.

Leave a Reply