Listing 05-01: Counting bills

##############################################################################
# Python From Scratch
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Site: https://pythonfromscratch.com
#
# File: listing\chapter 05\05.01 - Counting bills.py
# Description: Counting bills
##############################################################################

value = int(input("Enter the amount to pay:"))
bills = 0
current = 50
to_be_paid = value
while True:
    if current <= to_be_paid:
        to_be_paid -= current
        bills += 1
    else:
        print(f"{bills} bill(s) of ${current}")
        if to_be_paid == 0:
            break
        if current == 50:
            current = 20
        elif current == 20:
            current = 10
        elif current == 10:
            current = 5
        elif current == 5:
            current = 1
        bills = 0
Click here to download the file