Languages
[Edit]
EN

Python - reverse a string

0 points
Created by:
Teilsa
1315

In this article, we would like to show you how to reverse a string in Python.

Quick solution:

Where the statement [::-1] means:

  1. start at the end of the string,
  2. end at position 0,
  3. move with the step -1 (step backwards)

 

Practical example

Edit

In this example, we use a slice that steps backwards to reverse the string.

Output:

Alternative titles

  1. Python - how to reverse a string
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Python - string (popular problems)

Python - reverse string
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join