Why does Python evaluate strings/numbers as True in if statements yet myNumber == True returns False?

Viewed 188

The following will print 'ok':

if 5:
   print('ok')

Yet when I do:

print(5 == True) 

The output is False.

The same thing happens with strings. Why?

2 Answers
Related