Python String Slicing
codeaft@codeaft:~$ python3 ... >>> codeaft="Codeaft" >>> codeaft 'Codeaft' >>> len(codeaft) 12 >>> codeaft[0] 'K' >>> codeaft[11] 'w'
>>> codeaft[0:12:1] 'Codeaft' >> codeaft[0:12:2] 'KdnWno' >>> codeaft[0:12:3] 'KiWd' >>> codeaft[::-1]reverse the given string 'wodniWgnidoK'
>>> codeaft[::1] 'Codeaft' >>> codeaft[::2] 'KdnWno' >>> codeaft[::3] 'KiWd'
>>> codeaft[1::] 'odingWindow' >>> codeaft[2::] 'dingWindow' >>> codeaft[3::] 'ingWindow'
Comments and Reactions