title: How to replace multiple elements in 2d list on python?
body: <p>I'm struggling to print the 2d list by replacing the strings 7 and 9 by A and B. What am i doing wrong? Is there a better way of doing this?</p>
  
  <p>The function is supposed to go through the 2d list and when it finds the items 7 or 9, it replaces them by A and B and prints the changed 2d list.</p>
  
  <p>I get this error:
  <code>TypeError: list indices must be integers or slices, not list</code></p>
  
  <p>This is my code:</p>
  
  <pre><code>A = 7
  B = 9
  
  def display_list(A, B):
  mylist = [("01","02","03","04","05","06","07"),("08","09","10","11","12","13","14"),("15","16","17","18","19","20","21")]
  
      for row in mylist:
          row = list(map(int, row))
          for i in range(len(row)):
              if row[i] == A:
                  row[i] = "A"
              row = list(map(str, row))
              if row[i] == B:
                  row[i] = "B"
          row = list(map(str, row))
  
      mylist[row] = row
      print(mylist)
  
  display_list(A,B)
  </code></pre>
  
  <p>What I want is:</p>
  
  <pre><code>[("01","02","03","04","05","06","A"),("08","B","10","11","12","13","14"),("15","16","17","18","19","20","21")]
  </code></pre>