Answer: Python Puzzler #3559

The answer is A. The program prints:

I

This answer was checked by running the program for real.

Why?

word[5:6] is a slice: it starts at position 5 and stops before position 6. Positions count from 0.

Trace table

A trace table follows the program step by step. Here’s this one:

positionletter
0R
1O
2B
3O
4T
5I
6C
7S

The code again

word = "ROBOTICS"
print(word[5:6])

Try it: change one number in the program and predict the new output before you run it.