I have this simple code that returns the coin change for the cents. I was wondering how I can print this in dict format without having to type all this in the print statement while keeping the same format showing below?
cents =int(input("Please enter an amount in cents less than a dollar.\n"))
# assigned value
quarter = 25
dime = 10
nickel = 5
penny = 1
Q = cents // quarter
D = (cents%quarter) // dime
N = (cents% nickel) // nickel
P = (cents%nickel) // penny
print(f"Your change will be:\nQ: {Q}\nD: {D}\nN: {N}\nP: {P}")
output
Please enter an amount in cents less than a dollar.
87
Your change will be:
Q: 3
D: 1
N: 0
P: 2