Skip to content
UPEEC

Keywords

Reserved words with special meaning that can't be used as names — like if, for, def, class and return.

Beginner
Comments 0

Python 3.12 has 35 keywords: 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. match, case, type and _ are soft keywords — special only in certain places.

import keyword
print(keyword.kwlist)

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.