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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:05:51+00:00 2026-06-02T15:05:51+00:00

print liveCoords # displays [(0,0),(1,0),(2,0)] if population > 3 or population < 2: if

  • 0
  print liveCoords                                      # displays [(0,0),(1,0),(2,0)]
  if population > 3 or population < 2:
      if (j,i) in liveCoords:
          try:
              del liveCoords2[liveCoords2.index((j,i))]
          except:
              pass
  elif population == 3:
      if (j,i) in liveCoords:
          pass
      else:
          liveCoords2.append((j,i))
  print liveCoords                                       # displays [(1,0),(2,0)]

My question is not about how to do something specific, it is how my list liveCoords could possible be changed between those 2 points, from what I can see, nothing is being done that could possibly alter liveCoords, yet it is being altered.

  • 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-02T15:05:52+00:00Added an answer on June 2, 2026 at 3:05 pm

    Did you create liveCoords2 with the line liveCoords2 = liveCoords? If so then they are both references to the same list, so adding or removing elements in liveCoords2 would affect liveCoords as well.

    If this is the case, then changing the assignment to liveCoords2 = list(liveCoords) or liveCoords2 = liveCoords[:] would fix this. Note that both of these methods will create a shallow copy, if any elements in listCoords are mutable objects then listCoords2 will have references to the same objects as listCoords, this should be fine for your current code but if you do end up needing to create a deep copy you can use the copy module:

    import copy
    liveCoords2 = copy.deepcopy(liveCoords)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

try: print blah except KeyError: traceback.print_exc() I used to debug like this. I'd print
Python does not print traceback messages from exceptions raised in daemon threads. For example,
When I try to print a string in a Windows console, sometimes I get
print(How old are you) c = input() d = 1 The question is -
When I try to print an array contained in an instance of a struct
print <ul>; foreach ($arr as $value) { echo(<li> . $value[storeid] . . ($value[dvdstock] +
print() doesn't work in IE after opening a new window. It works in Chrome.
print "@_\n"; 4109 4121 6823 12967 12971 14003 20186 How do I sort it
Our print team saves raster images as .eps files. We need to convert about
How print format string passed as argument ? example.cpp: #include <iostream> int main(int ac,

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.