slice()

http://www.adilwaseem.com/

Introduction
Create a slice object. Return the string within requested parameters.

Syntax
slice(stop)
slice(start, stop[, step])

Parameters
number

Example 1
 >>> 
>>> b= "Python Lake"
>>> b[2:4]
'th'
>>> b[3:7]
'hon '

The method returns with:
 >>> 
>>> x="Python Lake"
>>> x[slice(1,4,2)]
'yh'
>>> x[slice(1,6,1)]
'ython'
>>> x[slice(1,10,3)]
'yoL'
>>> 

similar method:
 >>> a="I want to share some secrets with you."
>>> a[3:22]
'ant to share some s'
>>> 


Comments