Imagine that you're writing software for a credit card provider. Implement a program that will add new credit card accounts (Add), process charges (Charge) and credits (Credit) against them, validate card numbers (digits only, 12-16 chars; bonus: Luhn 10), and return card holder names in lexicographical order with their balance, or "error" if the card number is invalid.
Asked in the phone screen stage. Charges over limit are declined; credits may go negative; invalid cards are ignored. Reported follow-ups: validate card numbers with the Luhn algorithm.
def process_transactions(transactions):
transactions is a list of strings, each in one of these forms:
Add <name> <card_number> <limit>Charge <name> <amount>Credit <name> <amount>Return a list of strings in lexicographical order by card holder name. Each string must be "<name>: <balance>", or "error" if any card number is invalid.
def process_transactions(transactions):