Use this Python Syntax cheat sheet to troubleshoot errors and remember their common causes.
None | True | False | and | as | assert | break |
---|---|---|---|---|---|---|
class | continue | def | for | finally | exec | except |
else | elif | del | from | global | if | import |
in | is | lambda | try | return | raise | |
pass | or | not | yield | with | while | nonlocal |
Tip: In other programming languages, true
and false
are also written in lowercase. But in Python, they are always capitalized.
>>> import keyword
then >>> keyword.kwlist
in interpreter to check the keyword list.There are two types of errors in Python:
Are my keyword arguments in the correct order?
Am I missing or misspelling a keyword?
Is my spacing and indentation consistent?
Do my quotes match?
Have I closed all parentheses and brackets?
Is my programming environment set up properly?
Don’t forget that you can stay up to date on Python releases and tips by getting involved with the Python community. Try subscribing to the free Python email newsletter or connecting with your peers on the Python programming Slack channel.
This content has been made available for informational purposes only. Learners are advised to conduct additional research to ensure that courses and other credentials pursued meet their personal, professional, and financial goals.