Python program to print the given string in reverse order

Print the given string in reverse order

 
In this Python program, we will reverse the string and print the reversed string. The approach used here is one of the most efficient and easy way of reversing the string in python without iterating through the string or without using any in-built functions. We will use the slicing mechanism to reverse the string which takes 3 arguments in square brackets
 
  1. Start point.
  2. Endpoint.
  3. Order.
We will give value only for the third argument and change the order of representation of string
Python program for print the given string in reverse order

Algorithm

  • Step 1:- Start.
  • Step 2:- Take user input.
  • Step 3:- Use methrd of slicing and pass 3rd argument as -1.
  • Step 4:- Print String.
  • Step 5:- End.

Python program to reverse the string

#take user input
String = input('Enter the String :')
#pass 3rs argument as -1
String = String[::-1]
print(String)
Output:
Enter the String :JusticeForChutki
iktuhCroFecitsuJ