None == False | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

None == False

...is False, but why?

16th Jun 2020, 3:59 PM
Prof. Dr. Zoltán Vass
4 Answers
+ 5
But: bool(None) == False ...will be True :)
16th Jun 2020, 4:32 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 2
Thanks, Mirielle You’re right: >>> type(None) <class 'NoneType'> >>> type(False) <class 'bool'>
16th Jun 2020, 4:36 PM
Prof. Dr. Zoltán Vass
+ 2
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
18th Jun 2020, 11:11 AM
Josaphat NGOGA UWIZEYE
Josaphat NGOGA UWIZEYE - avatar
+ 1
"None" doesn't exist any data type . that's why
17th Jun 2020, 8:46 AM
Md Sahid Sk
Md Sahid Sk - avatar