Answers for "invalid literal for int() with base 10 python"

8

Python ValueError: invalid literal for int() with base 10:

# try using int(float(x)) as per the example below... Worked for me :)
int(float('55063.000000'))
# expected output: 55063.0
Posted by: Guest on May-18-2021
0

invalid literal for int() with base 10 python

#another way is to check if the entered number isdigit()
#that way you will ensure unhandled exception incase of erroneus data

number= input("What is your weight:")
if number.isdigit():
    kilos=int(float(number))
    print ("The weight of the person is:" + str(kilos))
else:
    print("Error - Please enter a proper weight")
Posted by: Guest on September-08-2021

Code answers related to "invalid literal for int() with base 10 python"

Python Answers by Framework

Browse Popular Code Answers by Language