Examples
Find the error in two lines of Python
A for loop missing its colon: the error found, why Python stops before printing anything, then the corrected line.
- 0:45
- Code problems
- Narrated by Erinome
- English
Made from a prompt
Find the error: for i in range(5) print(i)
Video transcript
In this video, we find and fix a Python syntax error.
Question one. Find the error: The first line reads for i in range, with five in parentheses. The indented second line reads print, with i in parentheses.
Notice that line one is missing a colon after the closing parenthesis. Python requires a colon at the end of a for loop header. Without it, Python raises a SyntaxError before either line executes, so nothing is printed.
The indentation of print is correct and does not need changing. Hence, the corrected first line is for i in range, open parenthesis, five, close parenthesis, colon.
More examples
-
How a neural network learns A network learning to spot cats: a guess, the error it gets back and a small correction, repeated, without a single equation. 1:25 · English -
Why the Moon seems to change shape Written from a NASA Space Place article: the half of the Moon the Sun always lights, and all eight phases in order. 0:59 · English -
كيف تجد قيمة س؟ A multiple-choice question written and narrated in Arabic: the equation is solved right to left in Arabic-Indic digits, every choice stays on the board, and the right one is circled in green. 1:07 · Arabic
Your topic, drawn in about a minute.
Your first 2 videos are free, up to 1 minute each, watermarked. No card required. Full product, every voice and style included.