myrmepropagandist on Nostr: I have a list of 3 python objects w/ 4 attributes. If exactly 2 are identical (not ...
I have a list of 3 python objects w/ 4 attributes. If exactly 2 are identical (not all 3, not none) I want to return False.
mylist=[ob1, obj2, obj3]
if len(set([x.attribute1 for x in mylist]))==2:
return False
if len(set([x.attribute2 for x in mylist]))==2:
return False
if len(set([x.attribute3 for x in mylist]))==2:
return False
if len(set([x.attribute4 for x in mylist]))==2:
return False
return True
feels clunky. what am i missing?
(can you guess what card game?)
mylist=[ob1, obj2, obj3]
if len(set([x.attribute1 for x in mylist]))==2:
return False
if len(set([x.attribute2 for x in mylist]))==2:
return False
if len(set([x.attribute3 for x in mylist]))==2:
return False
if len(set([x.attribute4 for x in mylist]))==2:
return False
return True
feels clunky. what am i missing?
(can you guess what card game?)