- In python slice () function is used to get a slice of elements from the collection of elements.
- It provides two overloaded slice functions there the first takes a single argument while the second function takes three arguments and returns a slice object.
- This slice object can be used to get a subsection of the collection.
- Start parameter is used to starting index where the slicing of object starts.
- Stop parameter is used to ending index where the slicing of objects stops.
- Step parameter is an optional argument that determines the increment between each index for slicing.
- It returns a sliced object containing elements in the given range only.

Sample Code
[pastacode lang=”python” manual=”%23%C2%A0Python%C2%A0slice()%C2%A0function%C2%A0example%C2%A0%C2%A0%0A%0A%23%C2%A0Calling%C2%A0function%C2%A0%C2%A0%0A%0Atup%C2%A0%3D%C2%A0(45%2C68%2C955%2C1214%2C41%2C558%2C636%2C66)%C2%A0%C2%A0%0A%0Aslic%C2%A0%3D%C2%A0slice(0%2C10%2C3)%C2%A0%23%C2%A0returns%C2%A0slice%C2%A0object%C2%A0%C2%A0%0A%0Aslic2%C2%A0%3D%C2%A0slice(-1%2C0%2C-3)%C2%A0%23%C2%A0returns%C2%A0slice%C2%A0object%C2%A0%C2%A0%0A%0A%23%C2%A0We%C2%A0can%C2%A0use%C2%A0this%C2%A0slice%C2%A0object%C2%A0to%C2%A0get%C2%A0elements%C2%A0%C2%A0%0A%0Astr2%C2%A0%3D%C2%A0tup%5Bslic%5D%C2%A0%C2%A0%0A%0Astr3%C2%A0%3D%C2%A0tup%5Bslic2%5D%C2%A0%23%C2%A0returns%C2%A0elements%C2%A0in%C2%A0reverse%C2%A0order%C2%A0%C2%A0%0A%0A%23%C2%A0Displaying%C2%A0result%C2%A0%C2%A0%0A%0Aprint(str2)%C2%A0%C2%A0%0A%0Aprint(str3)%0A%0A%C2%A0″ message=”” highlight=”” provider=”manual”/]Output

