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 January 2026. Register Now!

👉 For weekly programming practice and certification updates, join Sanfoundry’s official WhatsApp & Telegram channels

advertisement
Manish Bhojasia – Founder & CTO at Sanfoundry

I’m Manish, Founder & CTO at Sanfoundry, with 25+ years of experience across Linux systems, SAN technologies, advanced C programming, and building large-scale, performance-driven learning and certification platforms focused on clear skill validation.

LinkedIn  ·  YouTube MasterClass  ·  Telegram Classes  ·  Career Guidance & Conversations