0
How to reverse a line of string in Python.Example Input I am abhishek kumar output should be kumar ahishek am i
3 ответов
+ 3
U can use
[::-1] to reverse
For example
sen = "I am HrCoder"[::-1]
print(sen)
+ 3
Hint:
1. Split the string into an iterable using str.split() method
2. Reverse the iterable items order using slicing operator [ : : -1 ]
3. Join the iterable items using str.join() method.
+ 2
You can do slicing as mentioned by HrCoder or use reverse function