title: Please help me to solve this error on "UnboundLocalError: local variable 'b' referenced before assignment"
body: <p><strong>Please make me clear that when i have made 'b' a global variable on line 1. Then also it is showing an error</strong></p>
  <p><strong>Error:</strong>
  UnboundLocalError: local variable 'b' referenced before assignment</p>
  <p><em><em>Note</em> This code is a part of a larger code</em>*</p>
  <pre><code>global b
  
  b = 0
  
  def solve(operation):
  
      global a
      a = display.get()
  
      global ex
      if operation == &quot;-&quot;:
          if b == 0:
              ex = int(a)
          else:
              ex = int(b) - int(a)
      if operation == &quot;+&quot;:
          ex = int(a) + b
  
      b = int(a)
      a = ex
      global ans
      ans = ex
  
      display.delete(0, tkinter.END)
  </code></pre>