5 of 8
π While Loops
Part A: Start with 0 coins. Use a while loop to add 20 coins at a time until you have 100+. Print coins each time.
Part B: Start with 0 coins. Loop forever asking "Collect or stop?". If "collect", add 25 coins. If "stop", break. Print total at the end.
=== Part A ===
20
40
60
80
100
Done! 100 coins
=== Part B ===
Collect or stop? collect
25 coins
Collect or stop? collect
50 coins
Collect or stop? stop
Final: 50 coins
collect collect stop