November 22, 2024 |62.0K Views

    Reverse string in Python

      Share  4 Likes
    Description
    Discussion


    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. 


    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)

    Reverse string in Python : https://www.geeksforgeeks.org/reverse-string-python-5-different-ways/