mercredi 14 juillet 2021

How is a or b == None different from a==None or b == None [duplicate]

How is this statement interpreted

if a or b == None:

in this code

class Node:
    def __init__(self,value):
        self.value = value
        self.next = None

a=Node(4)
b=Node(5)
print(a,b)
print(a or b)
if a or b == None:  # I want to know if a==None or b==None
    print('s')

and on what basis a or b returns a also is there any other way to write if a==None or b==None

Aucun commentaire:

Enregistrer un commentaire