New course! Every coder should learn Generative AI!
Try a free lesson+ 1
type of "" is str
type of {} is dict
The 'is' keyword compares the memory address of two objects, if they are stored at the same location then it is true.
In case of strings, the python compiler may store two strings in the same location because strings are immutable. But this is implementation-specific.
In case of dictionary, a new object is always created.