The one-line slice method

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

The [::-1] slice means “from start to end, stepping backwards by one,” which walks the string in reverse.

Using reversed() and join()

text = "hello"
result = "".join(reversed(text))
print(result)   # olleh

reversed() returns an iterator, so join() stitches the characters back into a single string.

Reversing with a loop (how it works underneath)

text = "hello"
result = ""
for char in text:
    result = char + result
print(result)   # olleh

Each new character is placed in front of the result, which gradually builds the reversed string.

Which method should you use?

  • Slicing is the fastest and most Pythonic — use it by default.
  • reversed() + join() reads clearly when you want to be explicit.
  • The loop is best for learning what actually happens.

Frequently asked questions

Does reversing change the original string?

No. Strings in Python are immutable, so every method returns a brand-new string and leaves the original untouched.

How do I reverse the words instead of the letters?

Split into words, reverse the list, and join: " ".join(text.split()[::-1]).

New to slicing and loops? Our free Python course covers them step by step with a run-it-yourself editor.