1my_string = "Hey, This is a sample text"
2print(my_string[2:]) #prints y, This is a sample text
3print(my_string[2:7]) #prints y, Th excluding the last index
4print(my_string[2::2]) #prints y hsi apetx
5print(my_string[::-1]) #reverses the string => txet elpmas a si sihT ,yeH
1# The stride is the third (and optional) number in a slice.
2# The default value is 1.
3
4myString = "string"
5# prints every second character, beginning with the 0th index
6print(myString[::2]) # outputs "srn"
7# prints every second character, beginning with the last index and going backwards
8print(myString[::-2]) # outputs "git"
9
10myList = [0, 1, 2, 3, 4, 5, 6, 7]
11# prints every third character, beginning with the 0th index
12print(myList[::3]) # outputs [0, 3, 6]
13
14myTuple = ("a", "b", "c", "d", "e")
15# prints every character
16print(myTuple[::]) # outputs ("a", "b", "c", "d", "e")
17