title: How can I update an array by creating a new one and keeping the old one the same
body: <p>I have a class that has names as strings and you can change its names (you can see the class below)
  but when i change the names of the Squares with the <em>write</em> function it does something weird:
  <a href="https://i.stack.imgur.com/EJbzC.png" rel="nofollow noreferrer">trying to update a new array</a> it changes both the old and the new array</p>
  <p>I will also include the <em>write_word</em> function below as code</p>
  <p>Update:I also tried to add the .copy to the <em>write_word</em> function, Ill add the new version below
  Update2: I also tried to create the boards as a list, and write words into the list. I added both the array and the list versions of both create and write functions. In both of them the problem is the same, once I create a board and copy it and change the copy, both the original and the copy changes. This leads me to believe that the problem is caused by the class object and not the arrays.</p>
  <p>Update3: it seems like both the list and numpy have the same problem, I will now try to do the same thing without using class at all. I will update whether it works or not</p>
  <p>Update4: I didnt have to change the class at all and now my code does what it had to do thanks to the answer. I will still add the code that DOES work under the FINAL_write_word function.</p>
  <pre><code>class Square:
      def __init__(self, x,y):
          self.x = x
          self.y = y
          self.letter = &quot; &quot;
          self.num = 0
          
      def write(self, letter):
          if self.letter != &quot;!&quot;:
              self.letter = letter.upper()
          else:
              print(&quot;cannot write on black square&quot;)
      def clear(self):
          if self.letter != &quot;!&quot;:
              self.letter = &quot; &quot;
          else:
              print(&quot;cannot write on black square&quot;)
      def black(self):
          self.letter = &quot;!&quot;
      def isblack(self):
          if self.letter == &quot;!&quot;:
              return True
          else:
              return False
      def isfilled(self):
          if self.letter != &quot;!&quot; and self.letter != &quot; &quot;:
              return True
          else:
              return False
      def read(self):
          return self.letter
      def number(self,num):
          self.num = num
      def getnum(self):
          return self.num
      def __str__(self):
          image = &quot;  &quot; + self.letter
          return image
      def __repr__(self):
          image = &quot;  &quot; + self.letter
          return image
  
  def write_word(crossarray,indexes,word):
      print(&quot;now writing word:&quot;,word)
      temparray = crossarray
      for i, index in enumerate(indexes):
          row = int(index // 5)
          col = int(index % 5)
          temparray[row,col].write(word[i])
      return temparray
  
  def UPDATED_write_word(crossarray,indexes,word):
      print(&quot;now writing word:&quot;,word)
      temparray = crossarray.copy()
      for i, index in enumerate(indexes):
          row = int(index // 5)
          col = int(index % 5)
          temparray[row,col].write(word[i])
      return temparray
  
  def create_crossword(down,across,indexes,blacks):
      cross_array =  np.zeros((5,5), dtype=Square)
      for row in range(len(cross_array)):
          for col in range(len(cross_array[0])):
              cross_array[row,col] = Square(row,col)
      
      for name, index in enumerate(indexes):
          row = int(index // 5)
          col = int(index % 5)
          cross_array[row,col].number(name+1)
      
      for index in blacks:
          row = int(index // 5)
          col = int(index % 5)
          cross_array[row,col].black()
      return(cross_array)
  
  def create_crosslist(down,across,indexes,blacks):
      cross_list = []
      for row in range(5):
          rowlist = []
          for col in range(5):
              rowlist.append(Square(row,col))
          cross_list.append(rowlist)
      
      for name, index in enumerate(indexes):
          row = int(index // 5)
          col = int(index % 5)
          cross_list[row][col].number(name+1)
      
      for index in blacks:
          row = int(index // 5)
          col = int(index % 5)
          cross_list[row][col].black()
      return cross_list
  
  def write_word_list(crosslist,indexes,word):
      print(&quot;now writing word:&quot;,word)
      templist = crosslist
      for i, index in enumerate(indexes):
          row = int(index // 5)
          col = int(index % 5)
          templist[row][col].write(word[i])
      return templist
  
  import copy
  def FINAL_write_word(crossarray,indexes,word):
      print(&quot;now writing word:&quot;,word)
      temparray = copy.deepcopy(crossarray)
      for i, index in enumerate(indexes):
          row = int(index // 5)
          col = int(index % 5)
          temparray[row,col].write(word[i])
      return temparray
  </code></pre>