Python Syntax Rules

Syntax is the structure that allows Python to understand your instructions. Explore the core rules: names, comments, strings, statements, indentation, and common syntax errors.

Identifiers and case

Python treats uppercase and lowercase names as different identifiers.

Why this matters A name is the handle Python uses to find a value in memory. If the spelling or case changes, Python sees a different name.
Good habit Use clear, consistent names and avoid relying on tiny case differences.

What Python sees

Python sees two different names: x and X.

This code is valid, but the two names are different.