Python Keywords

Keywords are reserved words of programming languages. Every word in a python program is classified as either a keyword or an identifier or an operator.

  1. The keywords can not be an identifier.
  2. The meaning of the reserved words or keywords has already been  explained to the Interpreter or compiler.

All python keywords are listed below :-

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

The above keywords may vary in different versions of Python. Some extra might get added to the language or some might be removed.

We can get the list of keywords in your current version by typing the following in python shell.

Using Intermediate mode :-

import keyword

Using Script mode :-

import keyword

This will print all the keywords of the current version of python in your system. The output of the above code :-

['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']

Note : We have discuss each keyword in detail. Checkout the tutorials here.