TechieDrill Your World Of Technical Tutorials

Posts Tagged ‘slicing’

Python Slicing – How to get substring

11.12.2009 · Posted in Python

What we call as substring in C/C++/Java/CSharp/VB is implemented by slicing in python. Slicing works something like this: name = ‘techiedrill’ Here, python treats the string as 0-t 1-e 2-c 4-h and so on… So, to get a part of the original string, all that needs to be done is use the : symbol. This is called slicing. first = name[:5]       ...