Continue task | Sololearn: Learn to code for FREE!

-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)

3/11/2022 2:42:37 PM

George A.

11 Answers

New Answer

+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.

+3

You enter data five times, and your code asks for data input an infinite number of times without receiving values.

+1

I mean like this: Cost = 0 n = 0 while n < 5: age = int(input()) if age > 3: Cost += 100 n += 1 print(Cost)

0

Do you know why the "need help" code still output the same result?

0

#add this in top n = 0 #add this in bottom: n+=1 print(Cost)

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)

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.

0

Thanks Shalomdev it worked