+ 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
4 Réponses
+ 2
1. b = [:] is invalid syntax
Did you mean b = a[:]?
2. If so, both are 96 when I check them
+ 1
1. Yes, I forgot 'a'. Thank you)
2. In PyCharm 120 is displayed, and in SoloLearn 96
+ 1
Aibek Zhaisanbay
Try running it in idle or the python shell
0
I thought it was a Python feature. Thank you a lot)