...: y = sorted(x)
In [35]: x
Out[35]: [5, 7, 3, 38, 7]
In [36]: y
Out[36]: [3, 5, 7, 7, 38]
In [37]: xx = x
In [38]: xx
Out[38]: [5, 7, 3, 38, 7]
In [39]: id(xx)
Out[39]: 1635703548744
In [40]: id(x)
Out[40]: 1635703548744
In [41]: xx = x.copy()
In [42]: xx
Out[42]: [5, 7, 3, 38, 7]
In [43]: id(xx)
Out[43]: 1635703377480
In [44]: x.sort()
In [45]: x
Out[45]: [3, 5, 7, 7, 38]
댓글 없음:
댓글 쓰기