def std_weight(height, gender) :
if gender == 1 :
weight = height * height * 22
print("A man of height {0} has a standard weight of {1}.format(height, float(round(weight,2))))
elif gender == 2 :
weight = height * height * 21
print("A woman of height {0} has a standard weight of {1}.format(height, float(round(weight,2))))
print ("Standard Weight Saving Program\n")
height = input ("Enter the key: ")
gender = input ("Enter your gender (Male: 1, Female: 2) : ")
std_weight(height, gender)
If I do it like this, it will end right away, so where should I modify it?
python
Try running the following code and see how I found out where the problem was.
I need to fix it in a different way, but I'm posting the following code to show you how to see what's wrong.
def std_weight(height, gender) :
print(gender)
print(type(gender))
print(height)
print(type(height))
height = int(height)
gender = int(gender)
if gender == 1 :
print(1)
weight = height * height * 22
print(weight)
print("A man of height {0} has a standard weight of {1}.format(height, float(round(weight,2))))
elif gender == 2 :
print(2)
print(type(height))
weight = height * height * 21
print(weight)
print("A woman of height {0} has a standard weight of {1}.format(height, float(round(weight,2))))
print ("Standard Weight Saving Program\n")
height = input ("Enter the key: ")
gender = input ("Enter your gender (Male: 1, Female: 2) : ")
std_weight(height, gender)
© 2024 OneMinuteCode. All rights reserved.