Reputation: 549
mylist[:]
and mylist[::]
?mylist[::0]
to raise an error since negative steps are allowed?Upvotes: 4
Views: 8067
Reputation: 14864
No difference between mylist[:] and mylist[::]
mylist[::0]
This implies from starting index to last index without any step, don't know in what world it would be possible.
Upvotes: 1
Reputation: 21315
Third element is for steps. When you write mylist[:]
it will assume step will be 1 which is same case in mylist[::]
.
If you write mylist[::0]
then it will raise error because steps can be +ve
or -ve
not 0
Upvotes: 0
Reputation: 799230
No. Both result in slice(None, None, None)
.
Positive strides go forwards. Negative strides go backwards. Zero strides go... nowhere? How exactly would that work? An infinite sequence of a single value?
Upvotes: 8