Editor

Reverse a String

Beginner · Write the code · from Python Strings: Create, Access, Slice, and Manipulate Text

From the lesson: Python Strings: Create, Access, Slice, and Manipulate Text

Think about your phone. Almost everything you see on the screen is text: names in your contacts, messages from friends, search results, notifications. Behind the scenes, all of that text is handled by strings.

Read the lesson

You are given a variable text set to "Python". Print the string reversed.

Expected output:

nohtyP

Use string slicing to reverse it in one step.

text = "Python"
# Print the reversed string using slicing

More Strings exercises

All Python exercises · 50 practice problems · Python Fundamentals quiz