+ 2
why empty dictionary not equal to None ?
4 ответов
+ 1
A empty dictionary is a dictionary. It has a type. None has no type. Something with a type can't be equal to something with no type.
0
Because the type is different.
Specifically, you can add a pair key:val to a dictionary, but not to a None
0
In Python, an empty dictionary or any other container(like lists, tuples, sets, etc) always evaluates to a Boolean False value, not None.
You can find the detailed explanation here..
https://programmersportal.com/how-to-check-if-a-dictionary-is-empty-in-python/
- 1
it's not none. it has no element. thats it