Predict-Then-Check Widget

Configured via JavaScript

Code, output, options, and explanations are passed as a plain config object.

Configured via HTML

The widget is described in a div.forma-predict-then-check block. The code lives in a <pre>; the actual output in a <samp>; options and explanations come from a <dl> where the <dd> starting with "Correct" marks the right answer.

What does this Python code print?

items = [1, 2, 3]
print(items[-1])
1
Wrong: -1 counts from the end, not the start.
3
Correct: items[-1] returns the last element.
[1, 2, 3]
Wrong: print(items[-1]) prints a single element, not the whole list.
IndexError
Wrong: negative indices are valid in Python.
3