calculate Output Change in the least amount of coins/notes for change using Phyton

Viewed 148

The code provided below is not giving the output for "calculate Output Change in the least amount of coins/notes for change". I am new with Phyton and trying to learn, so anyone can help me spotting out and correcting what I have done wrong?. This application must- take inputs: Time in, Time Out; Output Cost, then ask for Payment in and the calculate Output Change in the least amount of coins/notes for change. The code is asking for inputs but not giving an output of calculating output change in least amount of coins/notes for change.


def print_euros(money, val):
    while money <= val:
        print("£" + str(val), end=", ")
        money -= val
        return money


def print_p(money, val):
    while money <= val:
        print(str(val), end="p,")
        money -= val
        return money


in_hour, in_min = map(int, input().split(':'))

out_hour, out_min = map(int, input().split(':'))

payment_in = input().split(',')

money_in = []

for i in payment_in:
    money_in.append(int(i[1:]))

tot_money = sum(money_in)

tot_hours = 0

if out_hour <= in_hour:
    tot_hours = 24 - in_hour + out_hour

else:
    tot_hours = abs(out_hour - in_hour)
    tot_mins = 0

if out_min <= in_min:
    tot_mins = 60 - in_min + out_min

else:
    tot_mins = abs(out_min - in_min)

if tot_mins == 60:
    tot_hours += 1
    tot_mins = 0

output_cost = tot_hours * 3

print("Output cost : £" + str(output_cost) + "." + str(tot_mins))

rem_change = 0

if tot_mins > 0:
    rem_change = 100 - tot_mins
    tot_money = tot_money - output_cost - 1
else:
    tot_money -= output_cost

print("output change : ", end="")

tot_money = print_euros(tot_money, 20)

tot_money = print_euros(tot_money, 10)

tot_money = print_euros(tot_money, 5)

tot_money = print_euros(tot_money, 1)

rem_change = print_p(rem_change, 50)

rem_change = print_p(rem_change, 20)

rem_change = print_p(rem_change, 10)

rem_change = print_p(rem_change, 5)

rem_change = print_p(rem_change, 2)

rem_change = print_p(rem_change, 1)

0 Answers
Related