Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Write a python script to print the docstring(documentation string) of the input function.

0 votes
asked Jul 6, 2020 by Andres Forero (120 points)

def input():
‘’‘this is doc string’’’
return None
print(input.doc)
help(input)

what is my mistake?

3 Answers

0 votes
answered Jul 8, 2020 by Peter Minarik (86,040 points)

I'm not exactly sure what you're after.

If you want your function to return a value, you do not return None, but an actual value, which you can use later.

def input():
    return "Hello"

print(input())
0 votes
answered Jul 8, 2020 by MrStaceyMoore (140 points)
Use .__doc__ to access the doc string of a function in python.

def func():
    """
    hello world
    """
print(func.__doc__)
0 votes
answered Jul 8, 2020 by xDELLx (10,500 points)

‘’‘this is doc string’’’ to be changed to """this is doc string """

Note : use double quotes & not single quote.

print(input.doc)  to be changed to print input.__doc__

Please refer the documentation.

 

 

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...