2018年11月14日 星期三

[python] Lists are mutable. Intergers are immutable.


a=[1,2,3,4]
b=a
print(a is b)
b[0]='a'
print(a is b)
print(a)
print(b)


a=1
b=a
print(a is b)
b=2
print(a is b)
print(a)
print(b)

output>>
True
True
['a', 2, 3, 4]
['a', 2, 3, 4]
True
False
1
2

沒有留言: