Slicing Strings

Slicing Strings:
You can create substrings with the slicing notation. You can do this by placing two indices within square brackets. The first index marks the start of the substring while the second index indicates the index number of the first character you don’t want to include in the substring.
For example:
storing “Program” to a variable and manipulating the variable to produce the desired result:

>>>p="Program"
>>>p[3:6]
'gra'
Translate »