title: Keeping/Storing a running total outside of function from inside a function
body: <p>Hey i'm working on a small project for school and i need to keep a running tally outside of a function whilst re running the program inside the function for any number of times.I've tried different things but i cant get it to stop resetting the value of my tally any help would be appreciated.This is my code so far:</p>
  
  <pre><code>import sys
  r = open("teacherfine.txt","r")
  
  a = 0
  b = 0
  
  
  def f(enter):
      b = 0
      for line in r:
          if line.startswith(enter):
              c = line.split(",")
              print(c)
              print(c[1],"owes",c[2])
              global a
              a = a =+ float(c[2])
              d = input("Do you want to add another code?(yes/no)")
              if d == "yes":
                  z = input("enter code")
                  f(z)
              elif d != "yes":
                  print("the total owed was",a)
                  sys.exit()
  
  
  
  
  z= input("enter code")
  f(z)
  </code></pre>