This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Python insert operation on list
Type: enhancement Stage: resolved
Components: Versions: Python 3.3
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: ezio.melotti, vivek.ratnaparkhi
Priority: normal Keywords:

Created on 2013-08-17 18:03 by vivek.ratnaparkhi, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg195497 - (view) Author: Vivek Ratnaparkhi (vivek.ratnaparkhi) Date: 2013-08-17 18:03
Example 1:

mylist = ['a','b','c','d','e']

Output: ['a', 'b', 'c', 'd', 'e', 'f']

Example 2:

mylist = ['a','b','c','d','e']

Output: ['a', 'b', 'c', 'd', 'e', 'f']

Why should mylist.insert(len(mylist), x) be equivalent to mylist.insert(len(mylist)+1000000000, x)

Excepted Output: Should give index error.
msg195498 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2013-08-17 18:07
The docs say that:
  l.insert(pos, val)
is equivalent to:
  l[pos:pos] = [val]
The docstring also says that the value is inserted before pos, so .insert is working as documented.
Date User Action Args
2022-04-11 14:57:49adminsetgithub: 62970
2013-08-17 19:58:42ezio.melottisetstage: resolved
2013-08-17 19:28:15brett.cannonsetstatus: open -> closed
resolution: not a bug
2013-08-17 18:07:50ezio.melottisetnosy: + ezio.melotti
messages: + msg195498
2013-08-17 18:03:06vivek.ratnaparkhicreate