- In python some words are reserved to represent some meaning or functionality. Such type of words are called reserved words.
- There are 35 reserved words available in python.
- True, False, None
- and, or, not, is
- if, elif, else
- while, for, break, continue, return, in, yield
- try, except, finally, raise, assert
- import, from, as, class, def, pass, global, nonlocal, lambda, del, with
Remark
- All Reserved words in python contain only alphabet symbols.
- Except the following 3 reserved words, all contain only lower case alphabet symbols.
- True, False and None
Question
Print all reserved words in python?
Python
import keyword
print(keyword.kwlist)
Output
PowerShell
['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']
Ungraded Questions
Get ready for an exhilarating evaluation of your understanding! Brace yourself as we dive into the upcoming assessment. Your active participation is key, so make sure to attend and demonstrate your knowledge. Let’s embark on this exciting learning journey together!