• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
July 31, 2024 |60.5K Views

Reverse string in Python

  Share  1 Like
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/