Login and get coding
In this Bite you will complete
IntList, a subclass of
list, which should be able to do the following:>>> from intlist import IntList >>> mylist = IntList([1, 3, 5]) >>> mylist.mean 3 >>> mylist.median 3 >>> mylist.append(7) >>> mylist.append(1.0) >>> mylist.mean 3.4 >>> mylist.median 3 >>> mylist.append('a') ... TypeError >>> mylist.append([2, 3]) >>> mylist.append([2, 'a']) ... TypeError >>> mylist +=  >>> mylist += [1, 'a'] ... TypeError
As you see this special list is enriched with
medianproperties, and is restricted to
intvalues only, be it as appended individually or as
ints. Apart from overriding
append, you'll also need to tweak the
__iadd__(operator overloading) dunder methods here.
Enjoy and keep calm and code more Python!
Will you be Pythonista #120 to crack this Bite?
Resolution time: ~67 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 7.0 on a 1-10 difficulty scale.
» Up for a challenge? 💪