1) Reverse a string by using stack
Procedure:
- First create an empty stack
- Push each character one by one in stack
- Pop each character one by one and put them back to the string
2) Reverse a strung using reversed() method
In this method, we will use reversed() method and iterate over the reversed iterator to get the reversed string.
Python code to reverse a string
Output
need an explanation for this answer? contact us directly to get an explanation for this answer