title: Python second loop not detected
body: <p>I am using python and some arcpy modules (that I do not think are important for my question) to run a code containing three iterations (a loop with two smaller loops inside). My code looks like this: </p>
  
  <pre><code>file = r"C:Directory\File"
  cursor = arcpy.SearchCursor(file,fields)
  A = range(1,270)
  os.chdir ('C:\Directory')
  book = xlwt.Workbook()
  sheet1 = book.add_sheet('Sheet1',cell_overwrite_ok = True)
  for a in A:
  tot = 0
  result = 0
  for row in cursor:
      if row.getValue('Firstfield') == a:
          tot = tot + row.getValue('secondfield')
          print (tot)
      for row in cursor:
          print row.getValue('GTYS_Branc')
          if row.getValue('GTYS_Branc') == a:
              result= result + row.getValue(Field1) * ((row.getValue(Field2))/tot )
      sheet1.write((branch-1),0,finalIIIprob)
      sheet1.write((a-1),1,result)
      book.save('Excel.xls')
  </code></pre>
  
  <p>The code works but does not give me the results I want. I noticed that the problem is that it practically ignores the second internal loop and every iteration of the first internal loop after the first one. What could the problem be?</p>