Python Program to Reverse a String Without using Recursion

This is a Python Program to reverse a string without using recursion.

Problem Description

The program takes a string and reverses the string without using recursion.

Problem Solution

1. Take a string from the user.
2. Use string slicing to reverse the string.
3. Print the reversed string.
4. Exit.

Program/Source Code

Here is source code of the Python Program to reverse a string without using recursion. The program output is also shown below.

a=str(input("Enter a string: "))
print("Reverse of the string is: ")
print(a[::-1])
Program Explanation

1. User must enter a string.
2. By giving the increment value as -1, string slicing is used to reverse the list.
3. The reversed string is printed.

advertisement
Runtime Test Cases
 
Case 1:
Enter a string: hello
Reverse of the string is: 
olleh
 
Case 2:
Enter a string: test
Reverse of the string is: 
tset

Sanfoundry Global Education & Learning Series – 1000 Python Programs.

If you wish to look at all Python Programming examples, go to 1000 Python Programs.

🎓 Free Certifications on 300 subjects are live for December 2025. Register Now!

advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
I’m Manish - Founder and CTO at Sanfoundry. I’ve been working in tech for over 25 years, with deep focus on Linux kernel, SAN technologies, Advanced C, Full Stack and Scalable website designs.

You can connect with me on LinkedIn, watch my Youtube Masterclasses, or join my Telegram tech discussions.

If you’re in your 20s–40s and exploring new directions in your career, I also offer mentoring. Learn more here.