+ 2

why is the size of the second list less than the first

import sys a = [1, 2, 3, 4, 5] b = a[:] print (sys.getsizeof(a)) # 120 print(sys.getsizeof(b)) # 96

26th Apr 2021, 7:44 AM
Aibek Zhaisanbay
Aibek Zhaisanbay - avatar
4 Answers
+ 2
1. b = [:] is invalid syntax Did you mean b = a[:]? 2. If so, both are 96 when I check them
26th Apr 2021, 7:57 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
1. Yes, I forgot 'a'. Thank you) 2. In PyCharm 120 is displayed, and in SoloLearn 96
26th Apr 2021, 8:06 AM
Aibek Zhaisanbay
Aibek Zhaisanbay - avatar
+ 1
Aibek Zhaisanbay Try running it in idle or the python shell
26th Apr 2021, 8:10 AM
ChaoticDawg
ChaoticDawg - avatar
0
I thought it was a Python feature. Thank you a lot)
26th Apr 2021, 8:28 AM
Aibek Zhaisanbay
Aibek Zhaisanbay - avatar