[Tutor] insert into list index -1

Mats Wichmann mats at wichmann.us
Mon Sep 28 19:21:28 EDT 2020


On 9/28/20 10:47 AM, hemanth sai kumar wrote:
> Hi All,
> 
> Thank you all for helping the python community.
> 
> Regarding the insert into list index 0 and -1.
> 
> insert into 0 is reversing the list.
> 
> while inserting into -1 is showing as below. value 1 is fixed and further
> insert into -1 index is shifting -2 index value

Was there a question here?

A negative insertion index means count from the end. So using -1 means
insert just before the last element.




More information about the Tutor mailing list