Syntax
Syntax is the set of rules that define how code must be written in a programming language — the grammar and punctuation the computer requires to understand it.
General Programming
Just as English has rules about word order and punctuation, every programming language has syntax rules: where to put brackets, colons, semicolons, and indentation.
Breaking these rules causes a syntax error, and the program will not run until it is fixed.
Examples
Python
# Valid syntax
if x > 0:
print("positive")
# Syntax error: missing colon
if x > 0
print("positive")Output:
SyntaxError: expected ':'