+ 1

How do I reverse input with Python

Python

23rd Aug 2021, 4:48 PM
Confidence Eburue
Confidence Eburue - avatar
7 Answers
+ 3
Confidence Eburue print(input("Enter input : ")[::-1])
23rd Aug 2021, 5:05 PM
Kiran Deep Naidu
Kiran Deep Naidu - avatar
+ 2
You do slicing or can use .reverse () function also
23rd Aug 2021, 5:32 PM
Atul [Inactive]
+ 2
text=input() print(text[::-1])
24th Aug 2021, 3:10 AM
Sancho Godinho
Sancho Godinho - avatar
+ 1
Confidence Eburue Here's another possible work-around without slicing the string: def reverse(string): buff = "" for i in range(len(string) - 1, -1, -1): buff += string[i] return buff Edit: Self-liked my comment due to unwanted disliking.
25th Aug 2021, 5:54 AM
Calvin Thomas
Calvin Thomas - avatar
+ 1
var_name=input() print(var_name[::-1])
25th Aug 2021, 10:41 AM
Rohan Paul
Rohan Paul - avatar
0
You can also use reverse function for list , then rejoin to form a string. this might work... i=list(input()) i.reverse() j="".join(i) print(j)
25th Aug 2021, 12:50 AM
Arshad Ali
Arshad Ali - avatar