The below is the example of an index of a string:
+---+---+---+---+---+
| H | e | l | p | A |
+---+---+---+---+---+
0 1 2 3 4 5
-5 -4 -3 -2 -1
str="Name string"
slicingSlicing example: [start:end:step]
str[start:end] # itemsItems start through end-1
str[start:] # itemsItems start through the rest of the array
str[:end] # itemsItems from the beginning through end-1
str[:] # aA copy of the whole array
Below is the example usage:
print str[0]=Nstr[0] = N
print str[0:2]=Na2] = Na
print str[0:7]=Name7] = Name st
print str[0:7:2]=Nm2] = Nm t
print str[0:-1:2]=Nm2] = Nm ti