589
2017-10-17 06:14:09
2
이것 말고도... 아래 코드를 한번 생각해보세요. 굳이 del 과 insert 를 써야 했는지... 오히려 그로 인해 버그가 생길 가능성은 없는지.
SUNJOONG-DESKTOP ~ # python
Python 3.4.5 (default, Oct 1 2017, 16:35:08)
[GCC 5.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> a = [ 0, 1, 2, 3, 4, 5, 6 ]
>>> a
[0, 1, 2, 3, 4, 5, 6]
>>> a[6] = 100
>>> a
[0, 1, 2, 3, 4, 5, 100]
>>> del a[6]
>>> a
[0, 1, 2, 3, 4, 5]
>>> a.insert (6, 100)
>>> a
[0, 1, 2, 3, 4, 5, 100]
>>> a.insert (6, 200)
>>> a
[0, 1, 2, 3, 4, 5, 200, 100]
>>> a.insert (6, 300)
>>> a
[0, 1, 2, 3, 4, 5, 300, 200, 100]
>>> a[0:6] = [10, 11, 12, 13, 14, 15]
>>> a
[10, 11, 12, 13, 14, 15, 300, 200, 100]
>>>