+ 1
Problem
I don't understand what Is the problem with this challenge. I should do a bmi calculator. weight=int(input()) height=float(input()) x=0 while x<4: z=weight/height**2 print(z) if z<18.5: print('Underweight') elif z>=18.5 or z<25: print('Normal') elif z>=25 or z<30: print('Overweight') else: print('Obesity')
16 ответов
+ 10
D Shah 🎯⏳️ Pls avoid giving finished code as answer, because it makes the OP skip the most important part of learning. Prefer giving hints for the OP to find the solution instead.
+ 7
When you take user inputs you don't assign value to it. Like in your code, you are taking user input for both height & weight.
So, assigning value to x will not help in solving problem. Also there is no need of "while" here. Go through the problem description again. Try to understand properly.
Hope this helps.
+ 5
Thanks Emerson Prado for the reminder! Will keep in mind. Have edited my answer.
+ 4
Happy coding! 🖐️😎
+ 4
weight = int(input("Enter weight in kg: "))
height = float(input("Enter height in meters: "))
x = 0
while x < 4:
z = weight / height ** 2
print(z)
if z < 18.5:
print('Underweight')
elif z >= 18.5 and z < 25:
print('Normal')
elif z >= 25 and z < 30:
print('Overweight')
else:
print('Obesity')
x += 1
+ 2
Why are you using a loop? 🤔
+ 2
The loop never ends..
+ 2
My suggestion is don't use the loop for this problem and if u are using it so give the counter for x so loop will stop working when x is equal to 4.
+ 2
Asim Farheen.{-<-{R #, P #, R #, P# & KP#}->-} Pls see my answer to D Shah 🎯⏳️
That said, the code has several issues. Pls review this thread and, if you'd like, do the Python courses.
+ 1
i used a loop because that was the exercise on that too but also because i thought it was the best solution. I probably complicated my life and I thank you. Now I try Solo D Shah 🎯⏳️
+ 1
If you checked the result of your code, you would see four answers instead of one... 😎
+ 1
No, I think you're just in too much of a hurry... 😎
+ 1
I know to learn well I shouldn't have any. I will try to have more patience
+ 1
I tried to put x==4 so it would stop but still it wasn't the right reasoning for that challenge. I do however agree with you that it could be done that way so the loop is not infinite
DIVYANSH VIDHANI
0
It's true. I try. I'm stupid sometimes
0
x=0:
wgt=int input(input())
hgt=float(input())
bmi=wgt/(hgt**2)
if bmi<=16.5:
Printf ("Underweight")
elif bmi<=27:
Printf ("Normal")
elif bmi <= 38
Printf ("Overweight")
else:
Printf ("Obesity")
x+=1;