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 8877045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:22:21+00:00 2026-06-14T19:22:21+00:00

Variables in Python are just pointers, as far as I know. Based on this

  • 0

Variables in Python are just pointers, as far as I know.

Based on this rule, I can assume that the result for this code snippet:

i = 5
j = i
j = 3
print(i)

would be 3.

But I got an unexpected result for me, and it was 5.

Moreover, my Python book does cover this example:

i = [1,2,3]
j = i
i[0] = 5
print(j)

The result would be [5,2,3].

What am I understanding wrong?

  • 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-14T19:22:22+00:00Added an answer on June 14, 2026 at 7:22 pm

    We call them references. They work like this

    i = 5     # create int(5) instance, bind it to i
    j = i     # bind j to the same int as i
    j = 3     # create int(3) instance, bind it to j
    print i   # i still bound to the int(5), j bound to the int(3)
    

    Small ints are interned, but that isn’t important to this explanation

    i = [1,2,3]   # create the list instance, and bind it to i
    j = i         # bind j to the same list as i
    i[0] = 5      # change the first item of i
    print j       # j is still bound to the same list as i
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Python EPD Traits I can keep variables that depend on others up to
When I use python in interactive shell I can easily dump variables by just
i have string stored in python variables, and i am outputting a html that
In python, is there a way I can use instance variables as optional arguments
I really thought I understood Python variable referencing, so I'm confused why this code
I am currently programming a python-based datagram-Server using threads and all of that. I
I'm trying to figure out some C code so that I can port it
Hi as far as I see in Python variables are untyped. So now I
I'm just getting started in python, and either haven't read about this, or missed
How do global variables work in Python? I know global variables are evil, I'm

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.