Python Reverse a String
Given a string, reverse it and output it in reverse order.
Example 1: use string slicing
str
=
'
Runoob
'
(
str
[
::-
1
]
)
The output of the code above is:
boonuR
Example 2: use reversed()
str
=
'
Runoob
'
(
'
'
.
join
(
reversed
(
str
)
)
)
The output of the code above is:
boonuR
Python3 Examples