How to Reverse a String in Python

Reverse a string in Python using slicing [::-1], the reversed() built-in, or a loop, with notes on performance and readability.

Published September 17, 2026

The idiomatic way to reverse a string in Python is extended slice syntax: s[::-1].

s = 'hello'
reversed_s = s[::-1]
# 'olleh'

Steps

  1. Use slice notation [start:stop:step] with start and stop omitted and step set to -1
  2. step=-1 tells Python to walk the string backward, producing a reversed copy

How it works

Python strings are immutable, so s[::-1] returns a new string rather than modifying s in place. This slicing trick works on any sequence type, including lists and tuples.

Things to watch for

  • ''.join(reversed(s)) is an equally valid, slightly more explicit alternative that works the same way
  • Both approaches are O(n) and effectively equivalent in performance for typical string lengths

FAQ

Is s[::-1] the fastest way to reverse a string in Python?

Yes, in CPython it's implemented efficiently in C and is generally faster than a manual loop-based reversal.

More Python articles