{"id":28204,"date":"2022-08-28T14:59:59","date_gmt":"2022-08-28T09:29:59","guid":{"rendered":"https:\/\/python-programs.com\/?p=28204"},"modified":"2022-08-28T14:59:59","modified_gmt":"2022-08-28T09:29:59","slug":"python-slice-function","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-slice-function\/","title":{"rendered":"Python slice() function"},"content":{"rendered":"

In this article we are going to discuss about the slice() function in python with examples.<\/p>\n

slice() function in Python:<\/strong><\/p>\n

Based on the specified range, the slice() method returns a portion of an iterable as an object of the slice class. It works with string, list, tuple, set, bytes, or range objects, as well as custom class objects that implement the sequence methods, __getitem__() and __len__().<\/p>\n

Syntax:<\/strong><\/p>\n

slice(stop)\r\nslice(start, stop, step)<\/pre>\n

Parameters<\/strong><\/p>\n