Unit 2 Task 18 - Solution

Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.

Solution - Task 18: Charity jar total

← Back to task


One possible program:

total = 0.0

while True:
    donation = float(input("Donation amount (0 to finish): "))
    if donation == 0:
        break
    total += donation

print("Total raised:", total)