Python Tutorial Python Advanced Python References Python Libraries

Python - Keywords



Keywords are reserved words which can not be used as variable names, function names, or any other identifiers. Python has a number of keywords that are available for use in programming. A list of these keywords with brief description are mentioned below. For more details about any keyword, please visit its page.

Python Keywords

KeywordDescription
and A logical operator which returns true if both of its operands are true, else returns false.
as To create an alias.
assert For debugging.
break To terminate the program out of the loop containing it.
class To define a class.
continue To let the program to skip a block of codes for current iteration.
def To define a function.
del To delete an object.
elif Used in conditional statements, same as else if.
else Used in conditional statements.
except Used with exceptions, what to do when an exception occurs.
False Boolean value, result of comparison operations.
finally Used with exceptions, a block of code that will be executed no matter if there is an exception or not.
for To create a for loop.
from To import specific parts of a module.
global To declare a global variable.
if To make a conditional statement.
import To import a module.
in A membership operator which validates membership of an element in the sequence like list, tuple etc.
is To test if two variables are equal.
lambda To create an anonymous function.
None Represents a null value.
nonlocal To declare a non-local variable.
not A logical operator which returns true if its operand is false and returns false if its operand is true.
not in A membership operator which validates no-membership of an element in the sequence like list, tuple etc.
or A logical operator which returns true if either of its operands are true, else returns false.
pass A null statement, a statement that will do nothing.
raise To raise an exception.
return To exit a function and return a value.
True Boolean value, result of comparison operations.
try To make a try...except statement.
while To create a while loop.
with Used to simplify exception handling.
yield To end a function, returns a generator.