Introduction:
This program takes a string as input from the user and prints it in reverse order.
Code:
#Program to display string in reverse order
st = input("Enter a string: ")
for i in range(-1,-len(st)-1,-1):
print(st[i],end='')
Logic:
The program uses a for loop to iterate through the given string in reverse order, starting from the last character, and prints each character using the end parameter of the print() function to avoid printing a new line after each character.
Output:
Enter a string: Hello World
>> dlroW olleH