text = "StackOverflow"
#using python slicing, you can get different subsets of the above string
#reverse of the string
text[::-1] # 'wolfrevOkcatS'
#fist five characters
text[:5] # Stack'
#last five characters
text[-5:] # 'rflow'
#3rd character to the fifth character
text[2:5] # 'rflow''ack'
#characters at even positions
text[1::2] # 'tcOefo'
Babatunde Mustapha
- reputation score 2813
- 25 silver badges
- 22 bronze badges
Babatunde Mustapha
- reputation score 2813
- 25 silver badges
- 22 bronze badges
lang-py