slice()
Built-in FunctionPython 2.0+Intermediate
Creates a slice object for use in extended indexing
Quick Info
- Documentation
- Official Docs
- Python Version
- 2.0+
Learn by Difficulty
Quick Example
python
s = slice(1, 5, 2) nums = [0, 1, 2, 3, 4, 5, 6] print(nums[s])
slice() is a built-in function that creates a slice object for use in extended indexing.
Try in PlaygroundTags
builtinfunctioncoreindexingsequence