Answer: Python Puzzler #568

The answer is D. The program prints:

CC
AA
TT
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 2 times in a row.

Trace table

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

letterprinted
CCC
AAA
TTT

The code again

for letter in "CAT":
    print(letter * 2)

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