How to take an input and reverse it | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to take an input and reverse it

Reverse

21st May 2021, 10:28 AM
zaid raashid
zaid raashid - avatar
14 Answers
+ 6
print(input()[::-1])
21st May 2021, 10:33 AM
Atul [Inactive]
+ 7
input()[::-1]
21st May 2021, 10:31 AM
TOLUENE
TOLUENE - avatar
+ 4
zaid raashid it is correct
21st May 2021, 10:34 AM
Atul [Inactive]
+ 3
I and SAYED🇧🇩🇵🇸 has already answered your question
21st May 2021, 10:36 AM
Atul [Inactive]
+ 3
str = input() #taking input as string str = str[::-1] # reversing using slicing print(str)
21st May 2021, 10:37 AM
TOLUENE
TOLUENE - avatar
+ 2
zaid raashid [::-1] is slicing from backwards of the string.
21st May 2021, 10:38 AM
TOLUENE
TOLUENE - avatar
+ 2
zaid raashid i think you have skipped the lesson on slicing . search on google and learn more about slicing.
21st May 2021, 10:42 AM
TOLUENE
TOLUENE - avatar
+ 2
zaid raashid we didn't use list.reverse() because our input is string not a list.
21st May 2021, 10:42 AM
TOLUENE
TOLUENE - avatar
+ 1
Thank you all and specially sayed for taking out some time and helping me😃😃😃
21st May 2021, 10:43 AM
zaid raashid
zaid raashid - avatar
- 1
It doesn't work
21st May 2021, 10:33 AM
zaid raashid
zaid raashid - avatar
- 1
Write me a small programm plzz
21st May 2021, 10:34 AM
zaid raashid
zaid raashid - avatar
- 1
What does this[::-1] do can you plzz explain
21st May 2021, 10:37 AM
zaid raashid
zaid raashid - avatar
- 1
Why did you not use list.reverse()
21st May 2021, 10:38 AM
zaid raashid
zaid raashid - avatar
- 1
What is slicing
21st May 2021, 10:39 AM
zaid raashid
zaid raashid - avatar