0
I want to increment the global variable when i call a function but its giving me an error can some body help me out
x=0 def main(): print(x) x+=1 def check(): for I in range(10): main() check() expected output: 0 1 2 3 4 5 6 7 8 9 10 actual outpu: UnboundError: Local variable referenced before assignment
1 Respuesta
+ 3
Add "global x" at the beginning of the function main()