Reverse String in Python

  • Post category:String

In this article, you will see how to reverse string in Python. The string reverse means reversing the order of the characters in a string. The str[::-1] is a Python slice that reverses a string.

Step 1: Create a string

str = "CodeAllow"
print("str = ", str)
print("str type = ", type(str)

Step 2: Reverse string

print("Reversed = ", str[::-1])

Output:

str =  CodeAllow
str type =  <class 'str'>
Reversed =  wollAedoC

Free resources to learn advanced skills: AiHints and CodeAllow