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






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.