Reserved Words / Keywords in Python

Keywords in Python

In Python, Keywords are reserved words.  These words have special meaning to the Python interpreter. They are used to define the syntax and structure of the Python language. You cannot use keywords as identifiers (names for variables, functions, classes, etc.).

There are 35 keywords in pytthon.
  • True, False, None 
  • and, or, not, is 
  • if, elif, else 
  • while, for, break, continue, return, in, yield 
  • try, except, finally, raise, assert
  • import, from, as, class, def, pass, global, nonlocal, lambda, del, with, async, await

Note :

  • All the keywords only contains alphabets(a-z A-Z).
  • Excepet None, True and False, all other keywords are in lowercase.

Points to remember:

  • switch concept is not there in Python.
  • Similarly do while loop is not there in Python.
  • 'int','float','char' and 'double' such type of words are not reserved words in python, because Python is dynamically typed language.
We will cover dynamically typed language in later tutorials.


# Write a program that will print all the keywords 


import keyword
for kword in keyword.kwlist:
 print(kword, end = ' ')


Output :

False None True and as assert async await break class continue def del elif else except finally for from global if import in is lambda nonlocal not or pass raise return try while with yield



Comments