0

How to reverse a string?

For example: "Daniel" convert to "leinaD"

20th Oct 2022, 6:43 AM
unique
unique - avatar
4 odpowiedzi
+ 6
a=input() print(a[::-1]) As Yaroslav Vernigora said it is slicing operation...learn through python beginners course.
20th Oct 2022, 7:27 AM
Riya
Riya - avatar
+ 8
unique , we can also use the built-in function reversed(). since it returns a reversed object, we need to use join() to get a final string. several other ways for reversing are possible by using a for a loop or recursion or ...
20th Oct 2022, 12:06 PM
Lothar
Lothar - avatar
+ 3
Hi! place the word in the list and then use slices to display it in reverse order
20th Oct 2022, 6:53 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
- 1
Hi, please write a example code
20th Oct 2022, 7:03 AM
unique
unique - avatar