How to fix invalid literal for int() with base 10 in Python?

  • How to fix invalid literal for int() with base 10 in Python?

    Posted by Ikenna dike on August 17, 2023 at 2:45 pm

    Hello all.
    Please I have challenge on an assignment. I am getting this error invalid literal for int() with base 10 while trying to run a function I created to calculate BMI. I did a code like this:

    height = input("enter your height in m: ")
    weight = input("enter your weight in kg: ")
    h = int(height)
    w = int(weight)
    BMI = w/(h*h)
    print(int(BMI))

    Please assist.

    Ikenna dike replied 1 year, 4 months ago 2 Members · 2 Replies
  • 2 Replies

Log in to reply.