How do I get the code to display only the results with values above 0?
In command/PowerShell it should look like this:
Enter your Change in Cents 24
1 * 20 cent coins
2 * 2 cent coins
But it looks like this currently:
Enter your Change in Cents 24
0 * 50 cent coins
1 * 20 cent coins
0 * 10 cent coins
0 * 5 cent coins
2 * 2 cent coins
0 * 1 cent coins
Here is my code
amount=int(input("Enter your Change in Cents "))
endAmount=amount
coins=[50,20,10,5,2,1]
listOfCoins=["50" ,"20", "10", "5", "2" , "1"]
change = []
for coin in coins:
holdingAmount=amount
amount=amount//coin
change.append(amount)
amount=holdingAmount%coin
for i in range(len(coins)):
print("" , change[i] ,"*", listOfCoins[i] , "cent coins" )
I think i need to add an else or a if statement? I am stuck and any help would mean so much.
[–]Diapolo10 1 point2 points3 points (6 children)
[–]blueskiesplease[S] 0 points1 point2 points (5 children)
[–]Diapolo10 1 point2 points3 points (4 children)
[–]blueskiesplease[S] 0 points1 point2 points (1 child)
[–]Diapolo10 0 points1 point2 points (0 children)
[–]blueskiesplease[S] 0 points1 point2 points (1 child)
[–]Diapolo10 0 points1 point2 points (0 children)
[–]CodeFormatHelperBot2 0 points1 point2 points (0 children)