-1

So whenever I run this code it outputs the values I need, but also a "None" value at the bottom Why is that and how do I get rid of it?

insert = input("Insert Coin: ")

insert = int(insert)

amount_due = 50 - insert

def check_coins():
    if insert >= 0 and insert < 50:
        print("Amount Due:", amount_due)

    elif insert > 50:
        print(insert - 50)

    else:
        print("Amount Due:", amount_due)


print(check_coins())
Mihaly
  • 9
  • 2

1 Answers1

1

you are getting None because of printing the function call, and the function is returning None

print(check_coins())

You need not require the print along with the function call.

Can you try the following:

insert = input("Insert Coin: ")

insert = int(insert)

amount_due = 50 - insert

def check_coins():
    if insert >= 0 and insert < 50:
        print("Amount Due:", amount_due)

    elif insert > 50:
        print(insert - 50)

    else:
        print("Amount Due:", amount_due)


check_coins()
Jeril
  • 7,858
  • 3
  • 52
  • 69