Kyo
0
Q:

python list slice sybtax

# [start:stop:step]
# for example ...
l = [1, 2, 3, 4, 5]
l[1:4] # elements from 1 (inclusive) to 4 (exclusive)
l[2:5:2] # elements from 2 (inclusive) to 5 (exclusive) going up by 2
2
>>> a[1:4]
[2, 3, 4]
2
sample_list = [1,2,3,4,5,6]
new_list = sample[1:4]
# index slicing using index
# print(new_list) = [2,3,4,5]
1

New to Communities?

Join the community