Monday, 29 August 2016

Python program to reverse a string using reversed() function

A simple python program to reverse a given string. Here we are goin to use reversed() function. We can't directly print reversed as it is not a string but it returns type 'reversed'. So we will join it to a empty string.

Syntax : ''.join(reversed(str))

Refer below for screenshot and program,


input_string = str(input('Enter any string : '))
print("Reversed String is :" + ''.join(reversed(input_string)))


Python - Reverse a string using reversed() function

No comments:

Post a Comment