title: Python characters within a matrix
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/12680953/python-row-column-matrix-trouble">Python row, column, matrix trouble</a>  </p>
  </blockquote>
  
  
  
  <p>I'm writing a python program with with a given </p>
  
  <pre><code>matrix = [['A', 'B', 'C'], 
            ['D', 'E', 'F'], 
            ['G', 'H', 'I']]
  </code></pre>
  
  <p>I'm trying to write a code so that I can define the coordinates for each value in the matrix. I have this to define the rows and column to get a coordinate: </p>
  
  <pre><code>def getLoc(key, elem):
      row , col = 0 , 0
      for a in [j for i in key for j in i]:
          if a == elem:
              return row / len(key), col % len(key)
          col += 1
          row += 1
  </code></pre>
  
  <p>That works to give me the coordinate for the letter but to work from the coordinate to get the letter I use:</p>
  
  <pre><code>def find_char(key, row, col):
      for a in [j for i in key for j in i]:
          if a == row , col = 0 , 0
              return elem
  </code></pre>
  
  <p>This doesn't give me a character. Why not?</p>