+ 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

15th Aug 2022, 1:03 PM
Kgotso Malefetse
5 Antworten
+ 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..
15th Aug 2022, 1:07 PM
Jayakrishna 🇮🇳
+ 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
15th Aug 2022, 1:39 PM
Ipang
+ 1
Hi! when the age is less than three, you must interrupt the iteration of the cycle and return to its beginning.
15th Aug 2022, 1:11 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 1
Thank for your reply and yes tag are used description noted
15th Aug 2022, 2:22 PM
Kgotso Malefetse
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?
7th Sep 2022, 11:41 AM
Kgotso Malefetse