Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
BMI code
#3
(Sep-05-2023, 03:49 PM)deanhystad Wrote: You cannot use float numbers for start, stop, step in range(start, stop, step). This is what is giving the error. Also, range does not do what you think it does. You should read up about range() because you'll be using it a lot.

Do you need this?
if BMI in range(18.5 , 24.9):
    print  ("your BMI is IDEAL")
To get here we already know that the bmi >= 18.5 and that bmi <= 25 because the earlier if statements already caught all under and overweight cases. Think about the problem first, then think about the code.
tnx Mod you're right it was simple than i thought range() function was really bad i only needed <= and >= .thanks for advice
Reply


Messages In This Thread
BMI code - by Reznick - Sep-05-2023, 03:25 PM
RE: BMI code - by deanhystad - Sep-05-2023, 03:49 PM
RE: BMI code - by Reznick - Sep-05-2023, 07:22 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020