G
G
Govnokodddd2020-05-06 06:48:31
Python
Govnokodddd, 2020-05-06 06:48:31

Why does this happen when extracting a slice?

L = [0,1,2,3]
L[-1000:100]

Why does the interpreter output the entire list when it doesn't have that length?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dimonchik, 2020-05-06
@dimonchik2013

because you are in Python and not in Go
displays the intersection of sets, one fig to interpret
Go would swear, because it has to deal directly with addresses

D
Diamond, 2020-05-06
@falmaz

In python, the existing part will be trimmed accurately, if the elements do not fall into the interval, an empty list is returned. Retrieving element L[-100] will throw an index error.
More details are here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question