Python String Slicing
kodingwindow@kw:~$ python3
...
>>> kw="KodingWindow"
>>> kw
'KodingWindow'

>>> len(kw)
12

>>> kw[0]
'K'

>>> kw[11]
'w'

>>> kw[0:12:1] 'KodingWindow' >> kw[0:12:2] 'KdnWno' >>> kw[0:12:3] 'KiWd' >>> kw[::-1] reverse the given string 'wodniWgnidoK'
>>> kw[::1] 'KodingWindow' >>> kw[::2] 'KdnWno' >>> kw[::3] 'KiWd'
>>> kw[1::] 'odingWindow' >>> kw[2::] 'dingWindow' >>> kw[3::] 'ingWindow'
Advertisement