Python Practice › Function Programs › Program 7
Reverse a string
Write a Python function to reverse a string.
Input
"Python1234"
Output
4321nohtyP
Approach
- Return
text[::-1].
Solution
def reverse(text): return text[::-1] print(reverse("Python1234"))Output
4321nohtyP
Learn the concept
New to this topic? Read the lesson, then come back.