Python slice()

Facebooktwitterredditpinterestlinkedinmailby feather

Python slice() class

The slice() class return a slice object representing the set of indices specified by range(start, stop, step). 

Syntax

         or

Parameter

Start: This parameter represents an integer number specifying at which position to start the slicing, and by default, its value is 0.

Stop: This parameter represents an integer number specifying at which position to end the slicing.

Step: It is an optional parameter that represents an integer number specifying the step of the slicing. 

Return

The slice() function returns a slice object.

Example 1

Output

Example 2

Output

Facebooktwitterredditpinterestlinkedinmailby feather