What will be the output of the following Python code?

ICSE Class 10 Robotics & AI PYQ · 2026 Improvement · Section A

2(ix)1 Mark · 2026 · Section A · 2026 Improvement

What will be the output of the following Python code?

s = "Python"
print(s[: :-1])
Show SolutionHide Solution↓
nohtyP

The string "Python" is stored in the variable s. The slice s[::-1] uses a step of -1, which reverses the string by reading all its characters from the last to the first.

Hence, the output is nohtyP.

← Previous questionNext question →

Browse the free Robotics & AI sample bank