title: Calling the value of a variable inside for loop when writing to a text file
body: <p>I want to create a text file from python whereby I want the value of a variable to change iteratively inside the for loop. However, I am unable to call the value of the variable inside the loop. Instead it just prints the the variable as string. The code is as follow:</p>
  <pre><code>f = open('workfile.txt, 'w')
  for i in range (1,152):
  a = 1
  f.write('BEGIN PERIOD a \n')
  f.write('6 1 1200.0 90.0 \n')
  f.write('END PERIOD a \n')
  a +=1
  f.close()
  </code></pre>
  <p>Here, after the BEGIN PERIOD and END PERIOD inside the f.write function, I want the value of ''<strong>a</strong>'' to change every time the loop runs. However, the program prints ''<strong>a</strong>'' as a string. Kindly help me out.</p>