Let’s learn how to reverse string in Python using clever trick.
Say, we have a string which we need to reverse.
How to reverse a string?
Clever way to do that is to use [::-1]
my_string = 'abcdefgh' print(my_string) reversed_string = my_string[::-1] print(reversed_string)
This one is reversing the string. There is no need to use any additional Python function for reverse string purpose.