Unit 2 Task 22 - Solution

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

Solution - Task 22: Savings goal

← Back to task


One possible program:

goal = float(input("Savings goal ($): "))
balance = 0.0
weeks = 0

while balance < goal:
    weekly_savings = float(input("Saved this week ($): "))
    balance += weekly_savings
    weeks += 1

print("Goal reached in", weeks, "weeks. Balance:", balance)