How to reverse a string in Python?

Better Stack Team
Updated on February 3, 2023

To reverse a string in Python, you can use slicing with the step parameter set to -1. Here is an example:

 
original_string = "hello"
reversed_string = original_string[::-1]
print(reversed_string) # "olleh"