What is the output of the following code ?
x = 100 def scope_test(): global x print('x == ', x) x = 2 print('X is changed to == ', x) scope_test() print('x is at outer scope', x)
Inside the function we are making x to global using global keyword and changing x value to change will change all value of x to 2
Comment here: