Step 1: A free coffee?
Priya's card has 7 stamps and she's buying 4 coffees. That makes 11 stamps: a free coffee, and 1 stamp left on the card for next time.
Add the cups to the card first. stamps = stamps + cups works, and Python has a shorter way to
write it:
stamps += cups # the same as: stamps = stamps + cups
Then decide. When the card reaches STAMPS_FOR_FREE, the till announces the free coffee and takes
ten stamps off the card. An if with no else is fine: when the test is False, Python skips the
block and carries on.
Free coffee on the house!
Stamps on the card: 1
For someone with 2 stamps buying 3 cups, only the second line prints: Stamps on the card: 5. The
check tries both, and a card that lands on exactly 10.
stamps.py, the file you edit10 lines
# Bean There's loyalty card: one stamp per coffee, and every 10 stamps earn a free coffee.
STAMPS_FOR_FREE = 10
stamps = 7 # stamps already on Priya's card
cups = 4 # coffees she's buying now
# TODO (Step 1): add the cups to the card. At STAMPS_FOR_FREE or more, print the free coffee line
# and take STAMPS_FOR_FREE off the card. Then always print what's on the card:
# Free coffee on the house!
# Stamps on the card: 1