Educatifu
Open menu

Reverse a String

Easystrings

Print a string reversed.

Input

A single line containing the string s (it may contain spaces and symbols).

Output

The characters of s in reverse order.

Examples

Example 1

Input
hello
Output
olleh

hello reversed is olleh.

Example 2

Input
racecar
Output
racecar

A palindrome reversed is itself.

Example 3

Input
abc def
Output
fed cba

Spaces are characters too, so they move as well.

Constraints

  • 1 <= length of s <= 10^4

Hints

Reveal hint 1

You do not need a loop in most languages — many have a built-in way to reverse a sequence.

Reveal hint 2

In Python, slicing with a step of -1 reverses a string: `s[::-1]`.

Reference solution (spoiler — try it yourself first)

Approach

Read the line and emit its characters in reverse order.

print(input()[::-1])

← All practice problems

Bring us the problem, not a perfect specification

Tell us what needs to change, who it affects and any important deadline. We will review the context and reply with useful next questions.

  1. 01Share contextDescribe the workflow, constraint or risk.
  2. 02Clarify togetherWe identify missing facts and useful options.
  3. 03Choose a startAgree a focused assessment or delivery step.
Start a conversation