Language Syntax
Slicing — Python syntax
Create a slice key for the receiver; built-in sequences interpret omitted bounds and negative steps and exclude the stop index. The receiver determines the result type and whether data is copied.
Formal Syntax & Structure
python syntaxpython
object[start:stop:step]Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| start | expression | First bound; omitted means receiver-defined default. |
| stop | expression | Exclusive bound for built-in sequences. |
| step | expression | Stride; omitted means default. |
Return Value
object
Value obtained by evaluating this expression; see description for context and constraints.
Working Example
Example Snippetpython
items='ABCDE'print((items[1:4:2],items[::-1]))