In Python, variable names cannot start with a number and cannot contain any special characters except for the underscore (_). Also, Python has a list of reserved words that cannot be used as variable names. Examples of these reserved words include:
Follow Podcast on Spotify
- and
- as
- assert
- break
- class
- continue
- def
- del
- elif
- else
- except
- False
- finally
- for
- from
- global
- if
- import
- in
- is
- lambda
- None
- nonlocal
- not
- or
- pass
- raise
- return
- True
- try
- while
- with
- yield
So any variable name that starts with a number or contains special characters except underscore(_) or one of the reserved words would be not a legal variable name in python.