- Keywords are the reserved words in python.
- Used as the variable name, function, or any other identifiers.
- They are case-sensitive.
- There are total 33 keywords.
Keywords in Python | ||||
---|---|---|---|---|
False | await | else | import | pass |
None | break | except | in | raise |
True | class | finally | is | return |
and | continue | for | lambda | try |
as | def | from | nonlocal | while |
assert | del | global | not | with |
async | elif | if | or | yield |
Example
The program will give all Python keywords.
import keyword keyWordList = keyword.kwlist print("Class Type: ", type(keyWordList)) print(keyWordList) print("nTotal Number Of Keywords: ",len(keyWordList))
Output:
Class Type: <class 'list'> ['yield', 'with', 'while', 'try', 'return', 'raise', 'pass', 'or', 'not', 'nonlocal', 'lambda', 'is', 'in', 'import', 'if', 'global', 'from', 'for', 'finally', 'except', 'else', 'elif', 'del', 'def', 'continue', 'class', 'break', 'assert', 'as', 'and', 'True', 'None', 'False'] Total Number Of Keywords: 33