Answer: Python Puzzler #385

The answer is D. The program prints:

1
What the program prints
Checked by running the program for real.

Why?

count goes through the string and counts how many times ‘u’ appears.

Trace table

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

lettermatches?
p
i
x
e
l
(space)
p
uyes
z
z
l
e

The code again

word = "pixel puzzle"
print(word.count("u"))

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