List insert at index that is well out of range - behaves like append

前端 未结 7 854
天命终不由人
天命终不由人 2020-12-11 00:37

I had a list

 a = [1, 2, 3]

when I did

a.insert(100, 100)

[1, 2, 3, 100]

as list was originally of siz

7条回答
  •  没有蜡笔的小新
    2020-12-11 01:00

    When you insert a single element into a list, the length of the list will grow by exactly one - not more, not less.

提交回复
热议问题