title: modify global variable value based condition with in a function in python
body: <p>I am declaring global variables before i run the user defined function.</p>
  
  <pre><code>global x
  x=2
  </code></pre>
  
  <p><strong>Now I want to change the value of the global variable based on some conditions with in the function it throws UnboundLocalError.</strong></p>
  
  <pre><code>UnboundLocalError: local variable 'x' referenced before assignment
  </code></pre>
  
  <p>i am changing the value of  global variable as follows.</p>
  
  <pre><code>if pd.isnull(x):
     x=1
  </code></pre>
  
  <p>The above code i used in user defined function.</p>
  
  <p>Anyone can help me to tackle this.</p>
  
  <p>Thanks in advance.</p>