- 1

# Continue task

I was told to write a code that print the cost for everyone who's age started from four to above while ages three to below output nothing. I coded this but Sololearn still didn't accept it, but I tested my code on an IDE called Replit and it worked as mentioned as my task at Sololearn. can someone tell me why Sololearn won't accept it? My code below: Cost = 0 while 0 < 5: age = int(input()) if age > 3: Cost += 100 print(Cost)

11th Mar 2022, 2:42 PM
George A.
8 Answers
+ 3
You have created an infinite loop, it's like writing: "while True:" Read the while loop lesson carefully. Also, the output of the result should be once.
11th Mar 2022, 2:49 PM
Solo
+ 3
You enter data five times, and your code asks for data input an infinite number of times without receiving values.
11th Mar 2022, 3:04 PM
Solo
+ 1
I mean like this: Cost = 0 n = 0 while n < 5: age = int(input()) if age > 3: Cost += 100 n += 1 print(Cost)
11th Mar 2022, 6:51 PM
Shadoff
0
Do you know why the "need help" code still output the same result?
11th Mar 2022, 2:56 PM
George A.
0
#add this in top n = 0 #add this in bottom: n+=1 print(Cost)
11th Mar 2022, 4:53 PM
Shadoff
0
Do you mean like this?: Cost = 0 n = 0 while n < 5: age = int(input()) if age > 3: Cost += 100 n += 1 print(Cost)
11th Mar 2022, 5:32 PM
George A.
0
in your line2,it is the same “while False”,it means all code which under the while will not work,so you need to change the condition of while.
11th Mar 2022, 8:24 PM
Yu-Hua Huang
0
Thanks Shalomdev it worked
13th Mar 2022, 11:01 PM
George A.