Example code:
name = "i am a student"
print(name[::-1])
Output:
tneduts a ma i
Example code:
name = "i am a student"
print(name[::-1])
Output:
tneduts a ma i
The last part of a slice denotes steps:
sequence[start:stop:steps]
As the last part is steps, it goes on the string on steps of -1:
i am a student
^
i am a student
^
i am a student
^
String_index[start:stop:step] You set the start to 0 and the end to the last element and the step -1 which mean its gonna go from first to last but reversed