Reverse a string

EasyFunction Programs · 7 of 39

Write a Python function to reverse a string.

Advertisement
Input
"Python1234"
Output
4321nohtyP

Approach

  1. Return text[::-1].

Solution

Python
def reverse(text):    return text[::-1] print(reverse("Python1234"))
Output
4321nohtyP
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More function programs

← All 39 Function Programs