belongs to collection: Python String Exercises
Given:
str1 = "PYnative"
Expected Output:
evitanYP
Hint:
reversed()
Solution1:Negative String slicing
str1 = "PYnative" print("Original String is:", str1) str1 = str1[::-1] print("Reversed String is:", str1)
Solution2:Using the reversed() function
str1 = "PYnative" print("Original String is:", str1) str1 = ''.join(reversed(str1)) print("Reversed String is:", str1)
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Hint:
reversed()
.Solution1:Negative String slicing
Solution2:Using the
need an explanation for this answer? contact us directly to get an explanation for this answerreversed()
function