Loading...
Loading...
Loading...
A payment machine reads payment amounts, one per line. The user types 0 to say that there are no more payments. The 0 itself is not a payment.
Print the total of the payments on one line as Sum: <total> and the number of payments on the next line as Count: <number>.
Sum: <total> and Count: <number>.Example 1
Input
5 10 0
Output
Sum: 15 Count: 2
Example 2
Input
0
Output
Sum: 0 Count: 0
Nothing before the 0.
Try the problem first. Open one hint at a time.
You do not know in advance how many numbers come, so use a while True loop.
Read a number in each round. If it is 0, leave the loop with break. Otherwise update the sum and the count.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor