0

I am declaring global variables before i run the user defined function.

global x
x=2

Now I want to change the value of the global variable based on some conditions with in the function it throws UnboundLocalError.

UnboundLocalError: local variable 'x' referenced before assignment

i am changing the value of global variable as follows.

if pd.isnull(x):
   x=1

The above code i used in user defined function.

Anyone can help me to tackle this.

Thanks in advance.

0 Answers0