python insert vs append

后端 未结 5 456
-上瘾入骨i
-上瘾入骨i 2020-12-03 05:19

I have written basic python snippets to first insert values in a list and then reverse them. I found that there was a huge difference of speed of execution between insert an

5条回答
  •  一个人的身影
    2020-12-03 05:45

    Insert method appropriately implementing in Queue . FIFO operation, inserts at the front of the list. ex :. items.insert(0,item)

    Append method appropriately implementing in stack . LIFO operation, inserts at the end of the list. ex :. items.append(item)

    When we are using insert data thru INSERT method make sure all indexes are re-sequenced.

提交回复
热议问题