Read the question, write Python on the right, then Run or Check.
QuestionHint and solution stay closed until you open them
Read one word and print it reversed.
Python slicing has a slick idiom for this: a step of -1 walks the string backwards.
Input. One line: a word.
Output. The word, reversed.
Examples
Input
code
Output
edoc
Input
Py
Output
yP
Hint
- word[::-1] reverses any sequence.
- Use .strip() to drop a stray trailing newline before reversing.
Show correct code
Peek only after you have tried. You can still Check your own version.
word = input().strip()
print(word[::-1])
main.pyPython · Ctrl + Enter runs
ResultIdle
Run to see output. Check grades the tests.