Which one is not a legal variable name in python? ( Full List )

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.


Hey, DDSRY is a Computer Science Student, Python Programmer, Indian Python Podcaster, and Content Creator. DDSRY Help Students To Learn Python Programming Language on Social Media. This Website (ddsry.com) is committed to helping students to Learn Python Programming Language in the easy and best way by DDSRY. @DDSRY