Answer: Python Puzzler #366

The answer is D. The program prints:

OOO
WWW
LLL
What the program prints
Checked by running the program for real.

Why?

A for loop can go through a string one letter at a time. Each letter is printed 3 times in a row.

Trace table

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

letterprinted
OOOO
WWWW
LLLL

The code again

for letter in "OWL":
    print(letter * 3)

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