I'm new to programming. I have written some Python code that has me confused. I have a list called "board" and I created a new list called "newlist". I created newlist using a function called cupdateboard(), that takes the list, board, and one other parameter as inputs. I'm not expecting board to change, yet it does. Can someone explain to me why board has changed, and how I could create newboard, based on board, without changing board?
def cupdateboard(cmove,lst):
newlst=lst
number=cmove+newlst[cmove]
newlst[cmove]=0
if number<=13:
for i in range(cmove+1,number+1):
newlst[i]+=1
elif number>13 and number<=19:
for i in range(cmove+1,14):
newlst[i]+=1
for i in range(0,number-13):
newlst[i]+=1
elif number>19:
for i in range(cmove+1,14):
newlst[i]+=1
for i in range(0,6):
newlst[i]+=1
for i in range(7,7+(number-19)):
newlst[i]+=1
return newlst
board=[4,4,4,4,4,4,0,4,4,4,4,4,4,0]
cmove=7
newboard=cupdateboard(cmove,board)
print(newboard)
print(board)
input("Press enter to quit")