3.6. Global variables - JulTob/Python GitHub Wiki

Global

It is impossible to assign a value to a variable defined outside a function without the global statement.

x= 50

def func()
  global x
  print('x is ', x)
  x = x+1
 

func()
# x is 50
func()
# x is 51
print(x)
# 51