Defining a Keyword
In programming, a keyword is a “reserved word” by the language which convey a special meaning to the interpreter. It may be a command or a parameter. Keywords cannot be used as a variable name in the program snippet.
Keywords in Python: Python language also reserves some of keywords that convey special meaning. Knowledge of these is necessary part of learning this language. Below is list of keywords registered by python .
False, elif, lambda,
None, else, nonlocal,
True, except, not,
and, finally, or,
as, for, pass,
assert, from, raise,
break, global, return,
class, if, try,
continue, import, while,
def, in, with,
del, is, yield,
Python in its language defines an inbuilt module “keyword” which handles certain operations related to keywords. A function “iskeyword()” checks if a string is keyword or not. Returns true if a string is keyword, else returns false.
for is a python keyword geeksforgeeks is not a python keyword elif is a python keyword elseif is not a python keyword nikhil is not a python keyword assert is a python keyword shambhavi is not a python keyword True is a python keyword False is a python keyword akshat is not a python keyword akash is not a python keyword break is a python keyword ashty is not a python keyword lambda is a python keyword suman is not a python keyword try is a python keyword vaishnavi is not a python keyword
How to print list of all keywords
Sometimes, remembering all the keywords can be a difficult task while assigning variable names. Hence a function “kwlist()” is provided in “keyword” module which prints all the 33 python keywords.
The list of keywords is : ['False', 'None', 'True', 'and', 'as', 'assert', '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']
This article is contributed by Manjeet Singh(S.Nandini). If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Check if a given string is a valid number (Integer or Floating Point) in Java
- Check if a given string is a valid number (Integer or Floating Point) | SET 1(Basic approach)
- Check if a given string is a valid number (Integer or Floating Point) in Java | SET 2 (Regular Expression approach)
- String slicing in Python to check if a string can become empty by recursive deletion
- Python | Check if a given string is binary string or not
- Python | Check for URL in a String
- Check if URL is valid or not in Java
- Check if the game is valid or not
- Check if the given chessboard is valid or not
- Python Set | Check whether a given string is Heterogram or not
- Python set to check if string is panagram
- Check whether triangle is valid or not if sides are given
- Check if any valid sequence is divisible by M
- Check if the given permutation is a valid DFS of graph
- Program to check if a date is valid or not