Home »
Python »
Python programs
Python program to print the list of all keywords
Here, we are going to learn how to print the list of all keywords in Python programming language?
Submitted by IncludeHelp, on March 23, 2020
To print the list of all keywords, we use "keyword.kwlist", which can be used after importing the "keyword" module, it returns a list of the keyword available in the current Python version.
In the below code, we are implementing a Python program to print the list of all keywords.
# Python program to print the list of all keywords
# importing the module
import keyword
# printing the keywords
print("Python keywords are...")
print(keyword.kwlist)
Output
Python keywords are...
['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']
Python Basic Programs »
ADVERTISEMENT
ADVERTISEMENT