Accounts to Review

Python for AIMedium+10 XP+10

Accounts to Review

A bank keeps a list of transaction amounts for each account. Refunds are negative numbers.

An account needs review if either:

  1. any single transaction is bigger than limit, or
  2. the account has at least one transaction and all of them are refunds (below 0).

Task: write accounts_to_review(accounts, limit). accounts is a dictionary of account name → list of amounts. Return the names that need review, in alphabetical order.

  • An account with no transactions never needs review.
  • An amount exactly equal to limit is fine.

Examples

accounts = {"ada": [20, 1500], "ben": [-5, -10], "cleo": [30, -2]}
limit = 1000
returns ['ada', 'ben']
accounts = {"dev": [], "eli": [500]}
limit = 500
returns []

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run