Python Keywords



The Python, keywords are the reserved words with a unique functions. These words cannot be used as a variables, function-names, class names. These are case-sensitive keywords.

Python's built-in methods and classes are not the same as the keywords. Built-in methods and classes are constantly present; however, they are not as limited in their application as keywords. When we assign a value to a keyword, it will raise an SyntaxError.

Python Keywords

Python contains thirty-five keywords in the most recent version, i.e., Python 3.8. Here we have shown a complete list of Python keywords −

Keyword Description

and

an logical operator

as

To create an alias

assert

For debugging

await

used to signify that the coroutine should pause execution until the awaited task completes

async

used to declare a function as a coroutine

break

used to control the loop

class

used to create a class

continue

To continue to the next iteration of a loop

def

used to define a function

del

to delete an object

elif

Used in conditional statement to check the condition

else

Used in conditional statement

except

Used in exception handling

False

Boolean value, result of comparison operation

finally

a block of code that will be executed no matter if there is an exception or not.

for

Used to create a for loop

from

used to import a function from a module

global

To create a global variable

if

To make conditional statement

import

To import a module

in

To check if an element is present in a iterable or not

is

To check whether both the values are equal or not

lambda

To create a lambda function

None

Represent a null value

nonlocal

To declare a non-local variable

not

A logical operator

or

A logical operator

pass

A null statement, statement that will not perform anything

raise

To raise an exception

return

To exit a function and return a value

True

Boolean value, result of comparison operation

try

to make a try in except statements

while

To create a while loop

with

Used to simplify exception handling

yield

To return a list of values from a generator
Advertisements