Operate an Encapsulated Savings Account

Complete SavingsAccount deposit and withdraw methods in the starter class. Initial balance is non-negative integer cents. Accept only positive deposits and withdrawals no greater than the balance; rejected operations leave it unchanged. Unknown operation names are rejected. Return balance and an accepted boolean for each [operation, amount] pair through the provided wrapper.

Difficulty: intermediate

Examples

  • [100,[["deposit",50],["withdraw",80],["withdraw",100]]]{"balance":70,"accepted":[true,true,false]}

Your solution

Python

Results

Python starts when you run or submit this challenge.

Back to Lesson