+ 1

What does :: mean?

6th Oct 2016, 5:31 AM
alex slater
alex slater - avatar
2 Antworten
+ 2
A default value is used if you omit one: [0:9] is 0 to 9 [:9] is beginning to 9 [9:] is 9 to end [1:9:2] is every second element starting at 1 through 9 [::] is beginning, to end, step size 1. Step size 1 is assumed for the first 3, where it's omitted. As for why you'd even want this: b=print('text') (b is set to 'none') my_list[b:b:b] still works as if b missing So you could legally return none for variables indexing a list and not crash. That's a guess.
10th Oct 2016, 6:25 PM
Kirk Schafer
Kirk Schafer - avatar
+ 1
if you have seen it concerning lists, mylist = [2, 64, 78, 43, 22] a = mylist[::] a is a copy of your mylist. It means: from the start, to the end. look after : slicing list
9th Oct 2016, 7:25 PM
Benedek Máté Tóth
Benedek Máté Tóth - avatar