0

Can anyone tell me why following code gives different answers?

>>> a='3x'
>>> b='3x'
>>> a is b
True

>>> a='3[x'
>>> b='3[x'
>>> a is b
False

--- EDIT ---

Thanks for the comment from Jean, so their ids are different because the strings are not cached, that make sense.

The thing that interested me is, when I try this in the PythonTutor website it returns True.

martineau
  • 119,623
  • 25
  • 170
  • 301
Deqing
  • 14,098
  • 15
  • 84
  • 131

0 Answers0