That's because 'global x' is different than 'fun x', 'fun x' overlaps/masks the 'global x', does whatever you do with it and then it ceases to exist. The mask is not there so former 'global x' is again the current 'x'.
As stated you can overcome this by using 'global x' inside the function, note the difference between fun1 and fun2
x = 10
print "'x' is ", x
def fun1(x):
print "'x' is local to fun1 and is", x
x = x**2
print "'x' is local to fun1 and is now", x
def fun2():
global x
print "'x' is global and is", x
x = x ** 2
print "'x' is global and is now", x
print "'x' is still", x
fun1(x)
print "'x' is not local to fun anymore and returns to it's original value: ", x
fun2()
print "'x' is not local to fun2 but since fun2 uses global 'x' value is now:", x
output:
'x' is 10
'x' is still 10
'x' is local to fun1 and is 10
'x' is local to fun1 and is now 100
'x' is not local to fun anymore and returns to it's original value: 10
'x' is global and is 10
'x' is global and is now 100
'x' is not local to fun2 but since fun2 uses global 'x' value is now: 100