Python Keywords

Python Keywords

Python has a set of reserved keywords that have special meanings in the language.

These keywords cannot be used as identifiers like: variable names, function names, class names, etc.

The following table details all of the Python keywords with links to respective tutorials for the keywords.

andA logical operatorPython logical AND operator
asTo create an aliasPython AS keyword
assertFor debuggingPython ASSERT keyword
breakTo break out of a loopPython break
classTo define a classPython class
continueTo continue to the next iteration of a loopPython continue
defTo define a functionPython Function
delTo delete an objectPython del
elifUsed in conditional statements, same as else ifPython elif
elseUsed in conditional statementsPython if else
exceptUsed with exceptions, what to do when an exception occursPython Try Except
FalseBoolean value, result of comparison operationsPython False
finallyUsed with exceptions, a block of code that will be executed no matter if there is an exception or not.Python finally
forTo create a for loopPython For loop
fromTo import specific parts of a modulePython from
globalTo declare a global variablePython global variable
ifTo make a conditional statementPython if
importTo import a modulePython import
inTo check if a value is present in a list, tuple, etc., or to iterate over a collection in For loop syntax.Python in keyword
isTo test if two variables are equalPython is
lambdaTo create an anonymous function Python Lambda Function
NoneRepresents a null valuePython None
nonlocalTo declare a non-local variable
notA logical operatorPython NOT logical operator
orA logical operatorPython OR logical operator
passA null statement, a statement that will do nothingPython pass
raiseTo raise an exceptionPython raise
returnTo exit a function and return a valuePython return
TrueBoolean value, result of comparison operationsPython True
tryTo make a try…except statementPython Try Except
whileTo create a while loopPython While loop
withUsed to simplify exception handlingPython with
yieldTo end a function, returns a generatorPython yield

Related Tutorials

Code copied to clipboard successfully 👍