Built-in Functions
slice()
Create a slice object for selecting part of a sequence.
slice(start, stop=None, step=None)
slice() stores the start, stop, and step used in slicing.
You can use the resulting object inside square brackets.
Parameters
| Name | Description |
|---|---|
| start | Where the slice starts. |
| stop | Where the slice stops before. |
| step | Optional spacing between selected items. |
Returns
A slice object.
Try it
Run it and change it
word = "Python" middle = slice(1, 5) print(word[middle])