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


None == False False, but why?

6/16/2020 3:59:21 PM

Prof. Dr. Zoltán Vass

7 Answers

New Answer


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


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


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.


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


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


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


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