Comparing Class Instances And Attaining Cumulative "score"
So, I have two instances of a class Person and I am trying to do some comparisons. sunis one of several attributes of each instance is defined by two randomly generated numbers. I
Solution 1:
In Python, this line
ifabs(self.sun - other.sun) == 2or4or8or10:
actually means
if (abs(self.sun - other.sun) == 2) or4or8or10:
Any non-empty value is regarded as True. so this expression will be always True. The proper form
if abs(self.sun - other.sun) in (2, 4, 8, 10):
The same goes fp the second if too
Post a Comment for "Comparing Class Instances And Attaining Cumulative "score""