- The number by default are interpreted as a decimal and if it is represented by
int(‘0x1’)then it gives an error asValueError. In this theint(string,base)the function takes the parameter to convert string to number in this the process will be likeint(‘0x1’,16) == 16. If the base parameter is defined as 0 then it is indicated by octal and 0x indicates it as a hexadecimal number
Shathana. S.R. Answered question July 7, 2023
Converting Strings to Numbers
Strings can be converted to numbers by using the int() and float() methods. If your string does not have decimal places, you’ll most likely want to convert it to an integer by using the int() method.
Shathana. S.R. Answered question July 7, 2023
