This is a Python Program to reverse a string without using recursion.
The program takes a string and reverses the string without using recursion.
1. Take a string from the user.
2. Use string slicing to reverse the string.
3. Print the reversed string.
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])
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.
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 – Python Programs.
To practice all Python programs, here is complete set of 150+ Python Problems and Solutions.