Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

In addition to indexing, slicing is also supported. While indexing is used to obtain individual characters, slicing allows you to obtain substring:

>>> word = 'Python'
>>> word[0:2]  # characters from position 0 (included) to 2 (excluded)
'Py'
>>> word[2:5]  # characters from position 2 (included) to 5 (excluded)
'tho'
>>> word[:2]   # character from the beginning to position 2 (excluded)
'Py'
>>> word[4:]   # characters from position 4 (included) to the end
'on'
>>> word[-2:]  # characters from the second-last (included) to the end
'on'
>>> word[:2] + word[2:]
'Python'
>>> word[:4] + word[4:]
'Python'
>>> word[4:42]
'on'
>>> word[42:]
''
Comment

PREVIOUS NEXT
Code Example
Python :: odoo 8 request.session.authenticate 
Python :: input what is your name python 
Python :: Python send sms curl 
Python :: python pynput hotkeys 
Python :: can you use pop on a string 
Python :: how to change the title of the top bar in python 
Python :: how to add field to django forms createview 
Python :: translating the mean of a data to a specific value 
Python :: Python RegEx Escape – re.escape() Syntax 
Python :: dynamic id python 
Python :: ABA Alphabet pyramid 
Python :: the most effective search algorithm in python 
Python :: decorrelation of data using PCA 
Python :: python loop take out element backwardly 
Python :: HIDING AND ENCRYPTING PASSWORDS IN PYTHON USING ADVPASS 
Python :: python package for facial emotion recognition 
Python :: get a list of colors that appear of the image python 
Python :: wn.synset vs wn.synsets in nltk 
Python :: How to Move and Delete Files in Python 
Python :: Create list element using algebraic operation 
Python :: Problème determinant algebre lineaire pdf mpsi 
Python :: how to give order in boxplot matplotlib 
Python :: examples of function decorators in Python 
Python :: provide a script that prints the sum of every even numbers in the range [0; 100]. 
Python :: la commande pop python 
Python :: why static kwyword not in python 
Python :: python how to d oa hello worl 
Python :: get last item in array python 
Python :: mute button tkinter 
Python :: Build the union of a list of RDDs 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =