None == False | SoloLearn: Learn to code for FREE!

0

None == False

...is False, but why?

6/16/2020 3:59:21 PM

Prof. Dr. Zoltán Vass

7 Answers

New Answer

+9

None is a datatype of the type "None" False is a datatype of the type "bool" So, they aren't the same in comparism

+5

But: bool(None) == False ...will be True :)

+4

Sometimes "type coercion" can occur, a phenomenal whereby a datatype is converted into another due to some functions or operators, and that's what will happen if bool(None) is compared with False. bool(None) will be considered as bool(0), and bool(0) is False False == False is True according to De'morgans law.

+3

Python has None, null, undefined etc does not exist as an Object in python, they can be only be seen as part of a description text in the console if something went wrong

+2

Thanks, Mirielle You’re right: >>> type(None) <class 'NoneType'> >>> type(False) <class 'bool'>

+1

"None" doesn't exist any data type . that's why

+1

Prof. Dr. Zoltán Vass None and false are very different in type: None is a datatype of the type "None" False is a datatype of the type "bool" Thus when you type: None==False It will return false because these are not the same. But if you change your code and write: bool (None)==False. It will return true. Because none being the datatype none it will return a value of bool equal to zero. Thats why it will return true