Q:

Python program to print the list of all keywords

0

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.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now