Reverse String with Slice in Python

Level 121 keystrokes

Slices a string with a step of -1 to reverse it and prints the result.

Python code

# [::-1] walks the string backward with a step of -1, so it prints nohtyp
1print("python"[::-1])

Output

nohtyp
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this Python code and how often they appear.

  • :× 2
  • "× 2
  • -× 1
  • (× 1
  • )× 1
  • [× 1
  • ]× 1

More Python examples at level 1

← Python typing practice