What is a Python Keyword?

Updated: May 18


A python keyword is a known as reserve word which can’t use as a name of your variable, class, function etc. These keywords have a particular meaning and they are used for particular purposes in Python programming language. For example – Python keyword “for” is used for “for loop” so we can’t name a variable with the name “for” else it may cause compilation error. There are total 33 keywords in Python 3.6.


Python keywords

False def if raise

None del import return

True elif in try

and else is while

as except lambda with

assert finally nonlocal yield

break for not

class from or

continue global pass

Example of Python keyword

Using while keyword to create a loop for displaying the values of variables num greater than 6.


num = 10 while num>6: print(num) num -= 1


Output:

10 9 8 7


Recent Posts

See All

Python Modules

A module is a file containing Python definitions and statements. A module can characterize functions, classes and variables. A module can likewise incorporate runnable code. Gathering related code int

Command Line Arguments in Python

Command Line Arguments are the arguments that are specified after the name of the program in the command line shell of the operating system. Python gives different ways of dealing with these types of