Answers for "slice notation python"

1

is : and :: the same in python slice

a[-1]    # last item in the array
a[-2:]   # last two items in the array
a[:-2]   # everything except the last two items
Posted by: Guest on October-11-2020
0

slice notation python

a[::-1]    # all items in the array, reversed
a[1::-1]   # the first two items, reversed
a[:-3:-1]  # the last two items, reversed
a[-3::-1]  # everything except the last two items, reversed
Posted by: Guest on November-22-2021
0

slice notation python

a[-1]    # last item in the array
a[-2:]   # last two items in the array
a[:-2]   # everything except the last two items
Posted by: Guest on November-22-2021
0

slice notation python

a[start:stop:step] # start through not past stop, by step
Posted by: Guest on November-22-2021

Python Answers by Framework

Browse Popular Code Answers by Language