Here is a basic math problem. I want to calculate least amount of banknotes to be paid.
Here is my code and working well.
total_payment = int(input("Please enter the total amount: "))
Dollar50 = int(total_payment // 50)
remaining_money = total_payment % 50
Dollar20 = int(remaining_money // 20)
remaining_money = remaining_money % 20
Dollar10 = int(remaining_money // 10)
remaining_money = remaining_money % 10
Dollar5 = int(remaining_money // 5)
remaining_money = remaining_money % 5
Dollar1 = int(remaining_money // 1)
print("We need {0} 50 dollar.".format(Dollar50))
print("We need {0} 20 dollar.".format(Dollar20))
print("We need {0} 10 dollar.".format(Dollar10))
print("We need {0} 5 dollar.".format(Dollar5))
print("We need {0} 1 dollar.".format(Dollar1))
But i want to print only if that type of banknote is used. For example if total amount is 101 dollar than program prints
We need 2 50 dollar.
We need 0 20 dollar.
We need 0 10 dollar.
We need 0 5 dollar.
We need 1 1 dollar.
But i dont want to print the ones with 0 value. I only want it to print
We need 2 50 dollar.
We need 1 1 dollar.
This was an example of my struggle. I can not code this kind of loops or conditions. Thank you very much for any help.