Monday 11 July 2022

Python program to reverse a given string

  Python String  

Python program to reverse a given string. 

This program will read a string from user and prints reversed string.

Program Code :

# Python program to reverse a given string.

str=input("Enter your string:")
print("The original string is : " + str)

str_rev = str[::-1]
print("The reversed string is : " + str_rev)

Program Output :

Enter your string:Python Practicals 

The original string is : Python Practicals 

The reversed string is : slacitcarP nohtyP

Recommended Articles:

 


 Home 

 Next