I'm trying to understand this code and what I don't understand is " if integer % 2:
Code: Select all
class EvenOnly(list): def append(self, integer): if not isinstance(integer, int): raise TypeError("Only integers can be added") if integer % 2: raise ValueError("Only even numbers can be added") super().append(integer) e = EvenOnly() e.append(2)
raise ValueError("Only even numbers can be added")"
If 2 % 2 which 2 is an even number shouldn't it raise an error since it is true?