voidex/20-29 Areas/20 Programming/20.01 Python/variableNamingRules.md

1.1 KiB

title tags aliases
variableNamingRules
python
variables
syntax
variable names
naming rules
valid variables

[!note] Naming Rules for Python Variables
Variable names must follow these rules:

  1. Must be a single word (no spaces)
  2. Can contain letters, numbers, and underscores
  3. Cannot start with a number
  4. Cannot include special characters

[!example] Valid vs Invalid Variable Names

Valid Variable Names Invalid Variable Names
current_balance current-balance (no hyphens)
currentBalance current balance (no spaces)
account4 4account (starts with number)
42 42 (starts with number)
TOTAL_SUM TOTAL_$UM (no special characters)
hello 'hello' (no quotes allowed)

[!info] Related Notes
variableNamingBestPractices
comments
pythonSyntaxOverview