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
25
26
27
28
#getting clarity on aliasing
#first look at lists
# do an upvote please
L1=[1,2,3]
L2=L1
print("Aliasing of Lists : ")
print(L1 is L2) #True
print(L1,L2)
'''get Ture it indicates that both L1 and L2 are two references for the same objest '''
print(id(L1))
print(id(L2))
L1[0] = 5
print(L1,L2)
# that is why id's of L1 and L2 are equal
'''if we make changes in one list it will effect other because both are pointing to same object and also we know that lists mutable'''
#Now lets look at strings
print("What about strings:")
s1 ="string"
s2 = s1
print(s2 is s1) # True
#s1 ,s2 points to same object
''' as we know that strings immutable we can't modify the existing string'''
s3 = s2 + s1
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run