You can download this code by clicking the button below.
This code is now available for download.
Converts a string to an integer with support for different bases.
Technology Stack : int() function, exception handling
Code Type : Conversion function
Code Difficulty :
def string_to_int(s, base=10):
try:
return int(s, base)
except ValueError:
return None