Python help() Function

The help() function in Python is used, when we need to execute the built-in help system to get the description about any topic like method, object etc. For example:


The snapshot given below shows the output produced by the above Python code, demonstrating the help() function:

python help function

The output shows the description about input (the input() function).

Python help() Function Syntax

The syntax of help() function in Python, is:


where obj refers to an object.

Python help() Function Example

Here is an example of help() function in Python. This program allows user to enter the name of topic to print the help of that topic:

print("Enter the Name of Object: ", end="")
obj = input()

print("\n------The", obj, "in Python------")

The snapshot given below shows the sample run of above program, with user input chr:

python help function example

In above sample run, user enters chr as input, and because chr() is a function, therefore with the help() function, the brief description of this function is displayed on the output.

The above program can also be created in a way to continue receiving the object input to print the help of that object, until user enters quit to finish the program:

while True:
    print("\nEnter the Name of Object: ", end="")
    obj = input()

    if obj == "quit":

The sample run with some object inputs, is shown in the snapshot given below:

python help function program

Get Help about any Object at Run-time in Python

To get help about any object at run-time of the program in Python, just use following code:


The snapshot given below shows the initial output produced by this Python code:

help function in python

Now type any object and hit ENTER key to get the help about that specified object. To finish the program, type quit and hit ENTER key.

You can get the detail of any module, keyword, or whatever you want to get the help of, just type and hit ENTER key to see the detail about the specific topic in Python.

Python Online Test

« Previous Function Next Function »

Liked this post? Share it!