What error occurs when a colon is omitted after an if statement in Python?

if x > 10
    print("Greater")
                        

Options

  • A. TypeError
  • B. NameError
  • C. SyntaxError
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

C. SyntaxError

Detailed Explanation

Python requires a colon (:) after compound statements such as if, for, while and def. Omitting it causes SyntaxError.