Python Forum
Help creating a variable as a result
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help creating a variable as a result
#2
bmi is float, and you compare it with a lists - under_weight, normal_weight, over_weight. They will never be equal.
In this case you don't need lists, they will not do what you want anyway.
one way to do what you try is like this:
if 14 <= bmi < 19:
by the way, bmi = weight / Height ** 2 is enough, no need to explicitly cast to float. Also it's good to be consistent with respect to variable names - use height, not Height. These are also PEP* recommendations.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
Help creating a variable as a result - by Realen - Jun-18-2020, 03:41 AM
RE: Help creating a variable as a result - by buran - Jun-18-2020, 04:16 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [split] Creating a variable as a function DPaul 23 6,957 Sep-07-2020, 05:20 PM
Last Post: DPaul
  Creating a variable as a function JarredAwesome 4 2,893 Sep-06-2020, 05:08 AM
Last Post: buran
  creating a variable in a method and using in another method ridgerunnersjw 5 3,016 Oct-04-2019, 04:03 PM
Last Post: buran
  Guidance in Creating random output for a variable. Livne_ye 1 2,546 May-04-2019, 01:18 PM
Last Post: Yoriz
  Creating a variable in for loop dan789 9 4,234 Dec-19-2018, 06:23 PM
Last Post: nilamo
  Multiple "return" statements or "result" variable? WolfWayfarer 7 7,854 Jul-25-2018, 07:51 AM
Last Post: perfringo
  Creating Dynamic Variable Names Dragonexpert 3 8,181 Oct-22-2016, 02:17 PM
Last Post: Dragonexpert

Forum Jump:

User Panel Messages

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