Slicing is used to retrieve the subset of values. The basic slicing technique is to define a starting point, the stopping point, and the step size – also known as a stride. In this tutorial, we will see the Python slice notation, and how to use it effectively.

Python Slice Notation

Python slice() is an inbuilt constructor that creates the slice object representing the set of indices specified by range(start, stop, step). If you want to get specific list values specified by range then Python slice() is the solution.

First, we will create a  list of values.

## app.py

A = list(range(2,10,2))
B = list(range(9))

print("List A:",A)
print("List B:",B)

#python #python slice

Python Slice Notation: What is Slice Notation in Python
2.65 GEEK