Skip to main content

Python program to reverse string using for loop

Below is running program in python which accept input string from user. using for loop it is reversing the string.

# Sample python program to reverse string using for loop

inputString = input('\n\nEnter string to perform reverse operation\t')


reverseString='' #Declaring empty reverse string variable.

for ch in inputString:
    reverseString = ch + reverseString

print('Reverse of  ' ,inputString, '  is   =>',reverseString)

Output


Enter string to perform reverse operation	reverse
Reverse of   reverse   is   => esrever
>>>