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
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
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")
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us