Reserved Words
Introduction
Reserved words (keywords) are words that are reserved by the language to represent a specific meaning or functionality.
- You cannot use these words as identifiers
- They are already used internally by Python.
- Python has only 33 reserved words.
- Because Python has fewer keywords, it becomes easier to learn compared to many other languages.
List of Python Keywords
Python contains 33 reserved words.
Here is the complete list:
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
Key Characteristics of Python Keywords
1. Only Alphabet Characters
All Python keywords:
- Contain only letters (A–Z, a–z)
- No digits
- No special symbols
2. Mostly Lowercase
Almost all keywords are written in lowercase.
Only three keywords start with uppercase letters:
- True
- False
- None
3. Cannot Be Used as Identifiers
Keywords cannot be used as variable names, function names, or class names.
if = 10 # ❌ Invalid
4. No Data Type Keywords
In some languages like Java, you may see keywords such as:
- int
- float
- boolean
In Python, these are not keywords.
5. Missing Concepts Compared to Other Languages
Some concepts available in languages like C/Java are not present in Python.
- Python does not have a
switchstatement.Instead, it usesif-elif-else. - Python does not support
do-whileloops. Python useswhileloop instead.
How to Get Keywords Programmatically
Python provides a built-in module to view all keywords.
import keyword
print(keyword.kwlist)
Output:
['False', 'None', 'True', 'and', 'as', 'assert', 'break', ...]