0
num = '5'
result = num or None
print(result)  # 5

num = ''
result = num or None
print(result)  # None

I don't understand why this works because I thought "or" will check if one side is True and if so it will return True. But it returns either the value of num or None.

Nepo Znat
  • 3,000
  • 5
  • 28
  • 49

0 Answers0