PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Demo list copy technique
print("This technical makes a new variable but points to the same list in memory.")
un = [1,2,3]
un2 = un
print(un)
print(un2)
print("If you change an element, it affects both results")
un[0] = 4
print(un)
print(un2)
print("Instead of making two vars point to the same list, make a copy")
un = [1,2,3]
un2 = un.copy()
print(un)
print(un2)
print("Now changes to un will not affect un2")
un[0] = 4
print(un)
print(un2)
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run