When it is required to reverse a string without using recursion technique, simple negative indexing can be used.
Indexing helps the values to access the elements at a specific index.
Below is a demonstration for the same −
my_string = str(input("Enter a string that needs to be reversed: ")) print("The string after reversal is: ") print(my_string[::-1])
Enter a string that needs to be reversed: Jane The string after reversal is: enaJ