Coin change program is not working(Python)

Viewed 29
def coins(cents):
    penny = cents // 25
    quarter = cents // 25
    dime = (cents % 25) // 10
    nickel = cents % 25 % 10 // 5

    print("Number of Cents:"), cents
    print("Pennies:"), penny
    print("Nickels:"), nickel
    print("Dimes:"), dime
    print("Quarters:"), quarter

coins(int(input("Enter number of cents:")))

I'm trying to make a coin change program that's supposed to divide cents into pennies, nickels, dimes, or quarters. Whenever I run the program, none of the numbers show up and I'm not sure why. enter image description here

1 Answers

Because you ended the brackets before the variables

This should work:

def coins(cents):
    penny = cents // 25
    quarter = cents // 25
    dime = (cents % 25) // 10
    nickel = cents % 25 % 10 // 5

    print("Number of Cents:",cents)
    print("Pennies:", penny)
    print("Nickels:", nickel)
    print("Dimes:", dime)
    print("Quarters:", quarter)

coins(int(input("Enter number of cents:")))
Related