+ 1
while loop
total = 0 x = 0 while x<5: age = int(input()) if age <3: total +=100 x +=1 print(total) #Please help me. what am I doing wrong
5 Réponses
+ 3
When age is less than 3 , you are adding 100 to total and incremeting x. printing total.
But what you need is:
increment x each time in iteration, irrespecting of age value.. (add increment out side if) .
And add 100 when age is greater than Or equal to 3. ( use >=, instead < )
Print total, after completing while loop..
+ 3
And please, avoid writing your question, or task Description in the post tags. Tags serve a diferent purpose in Discuss forum
https://code.sololearn.com/W3uiji9X28C1/?ref=app
+ 1
Hi! when the age is less than three, you must interrupt the iteration of the cycle and return to its beginning.
+ 1
Thank for your reply and yes tag are used description noted
0
weight = int(input());
height = float(input());
x = weight/float(height*height);
if x < 18.5:
print("Underweight")
elif x > 25 and x < 30:
print("Normal")
elif x >= 25 and x < 30:
print("Overweight")
elif x >= 30:
print("Obesity")
# there are 5 Test Case, but only 2 is right.
#What else should I do to open the rest?