25 out of 25 users completed this Bite ...
Will you be Pythonista #26 to crack this Bite?
Average Bite difficulty 1-10 rating: 4.5
» Up for a challenge? 💪
Let's enrich an Account class by adding dunder (aka special) methods to support the following:
The provided template already does some setup for you.
- length of the object:
len(acc)returns the number of transactions
- account comparison:
acc1 >,<,>=.<=,== acc2returns a boolean comparing account balances
acc[n]shows the nth transaction on
list(acc)returns a sequence of account transactions
- operator overloading:
acc + intand
acc - intcan be used to add/subtract money
- string representation:
str(acc)returns NAME account - balance: INT
Check out the tests for more specifics. Good luck!