+ 1

What am I doing wrong?

I have been working on this code for a while now and I can’t figure out what I am doing wrong! I can’t tell if there are any other problems past the weight = int(input()) because the same error keeps showing up. while 1==1: weight = int(input()) height = float(input()) x = weight/height**2 if x < 18.5: print("Underweight") if x >= 18.5 and x < 25: print("Normal") if x >= 25 and x < 30: print("Overweight") if x >= 30: print("Obesity")

23rd Jun 2022, 8:34 PM
Jessica
Jessica  - avatar
2 ответов
+ 1
# Hi! You can try it now, after a small adjustment: weight = float(input()) height = float(input()) x = weight/height**2 if x < 18.5: print("Underweight") elif x >= 18.5 and x < 25: print("Normal") elif x >= 25 and x < 30: print("Overweight") else: print("Obesity")
23rd Jun 2022, 8:40 PM
Per Bratthammar
Per Bratthammar - avatar
+ 2
"while 1==1:" just means "while True:" This in turn means "do what I tell you to do in the indented block following you, until I tell you not to by a certain conditional (breaking out of loop)" while True: yada yada if bla bla: break So do you want to continually ask for input? I don't remember that exercise as being such. Just remove "While 1==1:" and unindent the 3 lines under it till no space left on each line, and should be good to go. Also: "if 18.5 <= x < 25:" is a syntax that works, in case you didn't know.
23rd Jun 2022, 8:40 PM
Korkunç el Gato
Korkunç el Gato - avatar