Answers for "valueerror: invalid literal for int() with base 10: 'id'"

8

ValueError: invalid literal for int() with base 10: site:stackoverflow.com

# Just for the record:
int('55063.000000')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '55063.000000'

# use this
int(float('55063.000000'))
Posted by: Guest on January-18-2021
0

valueerror: invalid literal for int() with base 10: 'id'

#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 "valueerror: invalid literal for int() with base 10: 'id'"

Python Answers by Framework

Browse Popular Code Answers by Language