в чем разница между двумя кодами

Первый код:

 if curDirection == 0:
    print(len(Snake[-1]))
    Snake[-1][0] -= speed
 elif curDirection == 1:
    Snake[-1][0] += speed
 elif curDirection == 2:
    Snake[-1][1] += speed
 elif curDirection == 3:
    Snake[-1][1] -= speed

Второй код:

if curDirection == 0:
    Upd = Snake[-1][:]
    Upd[0] -= speed
elif curDirection == 1:
    Upd = Snake[-1][:]
    Upd[0] += speed
elif curDirection == 2:
    Upd = Snake[-1][:]
    Upd[1] += speed
elif curDirection == 3:
    Upd = Snake[-1][:]
    Upd[1] = Upd[1] - speed

Snake.pop()
Snake.append(Upd)

Snake - deque() из list После выполнения кусков кода Snake изменяется по-разному.. Почему?


Ответы (0 шт):