0

Jupyter output

On https://www.online-python.com/ , I have got True which I suppose to be the correct the answer since tuples are immutable. Thus can be saved in same memory space. Does anyone have any explanation?

3
  • x = ('apple', 'banana') y = ('apple', 'banana') print(x == y) Commented Dec 28, 2023 at 1:35
  • 1
    The explanation is that the implementation of the REPL is allowed to do it either way. Aside from None, the is keyword is really only useful for checking for object identity that the program deliberately arranges (for example, by doing y = x). Please see the linked duplicate for details. Commented Dec 28, 2023 at 1:37
  • print(x is y). It worked for Python 3.12.1 Commented Dec 28, 2023 at 1:37

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.