Python

Python Menu

Python

Python slice() Function - Definition, Syntax, Parameters, Examples

Definition

The slice() function returns a slice object.

Syntax

slice(start, end, step)

Parameters

Parameter Description
start Optional. An integer number specifying at which position to start the slicing. Default is 0
end An integer number specifying at which position to end the slicing
step Optional. An integer number specifying the step of the slicing. Default is 1

Examples

a = ("a", "b", "c", "d", "e", "f", "g", "h") x = slice(3, 5) print(a[x])

Introduction

Python Basics

Python Advance

Data Science Python Tutorials

Python Functions and Methods