Reverse string in Python (6 different ways)
Python string library does’nt support the in-built “reverse()” as done by other python containers like list, hence knowing other methods to reverse string can prove to be useful. This article discusses several ways to achieve it.
The original string is : Geeksforgeeks The reversed string(using loops) is : skeegrofskeeG
Explanation : In above code, we call a function to reverse a string, which iterates to every element and intelligently join each character in the beginning so as to obtain the reversed string.
Time complexity : O(n)
Auxiliary Space : O(1)