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

Print the list of all keywords

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.

Learn: Python Keywords, Keywords Reference

Python program to print the list of all keywords

In the below code, we are implementing a program to print the list of all keywords in Python.

# 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 »

Related Programs

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.