Implement a class intlist which a list that stores only integers. You MUST subclass list. Please note
Question:
Implement a class intlist which a list that stores only integers. You MUST subclass list. Please note the following:
constructor –can be passed a list of ints, or, by default constructs an empty intlist.
append, insert,extend – can also be used to add ints to an intlist. If you don’t know how extend works for a list, look it up. All should raise errors if a non-int is added.
__setitem__- can be used for item assignment using an index. Raises error if non-int is used.
odds() – write a method odds() which returns an intlist consisting of the odd int’s. They should not be removed from the original.
evens() – same as odds(), but for even ints
NotIntError – also write an Exception class NotIntError that subclasses Exception.
NotIntError – a NonIntError should be raised when client code attempts to place something other than an int in an intlist. This can happen in three ways (all shown in code below):
append
insert
The constructor – when passed a list that contains something other an int
Systems analysis and design
ISBN: 978-0136089162
8th Edition
Authors: kenneth e. kendall, julie e. kendall