September 2026
1051 pages
35h 4m
English
Perhaps you’ve already played with the sample program from Section 4.3 and come across the following or similar output from the interpreter:
File "hello_world.py", line 10 if attempt != secret ^SyntaxError: expected ':'
This is an error message that indicates a syntax error in the program. Can you tell what exactly the error is in this case? Correct: the colon at the end of the line is missing.
Python provides important information when outputting an error message, which is helpful in troubleshooting:
The first line of the error message indicates in which line and within which file the error occurred. In this case, it’s line 10 in the hello_world.py file.
The middle part shows the affected section of the source ...
Read now
Unlock full access