I am having troubles understanding the scope concept in Python. When I use the following code:|
x = 100
def printer(x):
x = 25
print(x)
printer(x) -> prints 25
print(x) -> prints 100
In the example above I understand the variable 'x' only has 25 as value in the function. When I try to do the same with a list, my output is different. See code below:
board = ['','']
def printer():
board[0] = 'X'
print(board)
printer() --> prints ['X', '']
print(board) --> also prints ['X', ''] || Here I was expecting to print ['','']