0
#a bmi converter

a = input("What is your mass unit,type'kg'or'lb' : ")

ax = float(input("enter mass"))

b = input("What is your height unit,type'ft'or'cm' : ")

bx = float(input("enter height"))

if a == "lb":
    ax=ax*0.453592
elif a == "kg":
    ax=ax    
else:
    print("invalid input")

if b == "ft":
    bx=bx*30.48
elif b == "cm":
    bx=bx*0.01
else:
    print("invalid input")

bmi = ax/(bx**2)
w=int
if bmi <18.5:
    w="underweight"
elif bmi==range(18.5,24.9):
    w="normal weight"
elif bmi==range(25,29.9):
    w="overweight"
elif bmi>30:
    w="obese"

print ("your bmi is",bmi,w)

Which gives the following error:

TypeError: 'float' object cannot be interpreted as an integer

So i need the range in decimals

but it doesnt accept int values

Swier
  • 4,047
  • 3
  • 28
  • 52
Nasr Ullah
  • 53
  • 4
  • Note: "decimal" is representation in base 10. In your code, the only decimal you have is the input strings. Internally, you have binary (base 2) representation. BTW: Please extract a [mcve] next time, much of your code above is not necessary to demonstrate the problem. As a new user, also take the [tour] and read [ask]. – Ulrich Eckhardt Nov 12 '20 at 11:58
  • `bmi` can not be equal to a range, rather it would be contained within a range. – JanLikar Nov 12 '20 at 12:14

1 Answers1

1

Replace

elif bmi==range(18.5,24.9):
    w="normal weight"

with

elif 18.5 <= bmi <= 24.9:
    w="normal weight"
Ron Serruya
  • 3,988
  • 1
  • 16
  • 26