Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8913037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:21:38+00:00 2026-06-15T04:21:38+00:00

The is operator does not match the values of the variables, but the instances

  • 0

The is operator does not match the values of the variables, but the
instances themselves.

What does it really mean?

I declared two variables named x and y assigning the same values in both variables, but it returns false when I use the is operator.

I need a clarification. Here is my code:

x = [1, 2, 3]
y = [1, 2, 3]

print(x is y)  # False
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T04:21:39+00:00Added an answer on June 15, 2026 at 4:21 am

    You misunderstood what the is operator tests. It tests if two variables point the same object, not if two variables have the same value.

    From the documentation for the is operator:

    The operators is and is not test for object identity: x is y is true if and only if x and y are the same object.

    Use the == operator instead:

    print(x == y)
    

    This prints True. x and y are two separate lists:

    x[0] = 4
    print(y)  # prints [1, 2, 3]
    print(x == y)   # prints False
    

    If you use the id() function you’ll see that x and y have different identifiers:

    >>> id(x)
    4401064560
    >>> id(y)
    4401098192
    

    but if you were to assign y to x then both point to the same object:

    >>> x = y
    >>> id(x)
    4401064560
    >>> id(y)
    4401064560
    >>> x is y
    True
    

    and is shows both are the same object, it returns True.

    Remember that in Python, names are just labels referencing values; you can have multiple names point to the same object. is tells you if two names point to one and the same object. == tells you if two names refer to objects that have the same value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am wondering why the second map declaration (using the diamond operator) does not
I have a class which does not have copy constructor or operator= overloaded. The
How does the is operator determine if two objects are the same? How does
Possible Duplicate: What does the question mark and the colon (?: ternary operator) mean
This prototype does not match the definition. How do i fix it? I threw
I have two vectors and want to compare their contents (strings) but this does
why does void operator<<(ostream out, Test &t); return an error whereas void operator<<(ostream &out,
What does the /= operator in C# do and when is it used?
Does java have an equivalent operator or language construct as the verbatim operator(@) in
Why does the initialisation of C++ references works without the adress-of operator (which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.