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.

classification
Title: Deleted positions lists
Type: behavior Stage: resolved
Components: Versions: Python 3.9
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith, iqanansoft
Priority: normal Keywords:

Created on 2021-02-02 08:06 by iqanansoft, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg386130 - (view) Author: iqanansoft (iqanansoft) Date: 2021-02-02 08:06
Hello, in a list, when using the slice notation, if a higher rank is placed than the new data, the positions of the list are removed 

list_test=[0,1,2,3,4,5,6]
list_test[2:4]=["two","three"]

result-->[0,1,'two','three',4,5,6]

this is correct, but this


list_test=[0,1,2,3,4,5,6]
list_test[2:21]=["two","three"]

result-->[0,1,'two','three']

deleted last positions
msg386131 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2021-02-02 08:19
That's the correct behavior. The elements given by the start and end range are replaced by what's on the right hand side of the assignment. They don't need to be the same length.

>>> list_test=[0,1,2,3,4,5,6]
>>> list_test[2:5] = ['two', 'three']
>>> list_test
[0, 1, 'two', 'three', 5, 6]
History
Date User Action Args
2022-04-11 14:59:40adminsetgithub: 87265
2021-02-02 08:19:10eric.smithsetstatus: open -> closed

nosy: + eric.smith
messages: + msg386131

resolution: not a bug
stage: resolved
2021-02-02 08:06:03iqanansoftcreate