You will work out balances from a ledger, and refuse a payment that the sender cannot afford.
Your tasks.
balance, return how many units name holds: the starting amount, plus every amount received, minus every amount paid, using the whole ledger.can_pay, return True if name has at least amount units, and False if not.pay, add the payment (sender, receiver, amount) to the end of the ledger only if can_pay allows it. Return True if it was added, False if not.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…