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])