Python Forum

Full Version: Need help in finishing my scripts
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am very new to python and need your help to fix below assignment.

write a python script to print the docstring(documentation string) of the input function in python 3.
what have you tried? Please, post your code in python tags, full traceback (if any) - in error tags
Yes.. I tried many ways as per my understanding...
docstring = input()
print('docstring=', docstring)
or
def docstring(a):
"""Documentation String"""
print(doctring.__doc__)
Note that input() is the result of calling the input function: what the user types in. The input function itself is input, without parentheses. That's what you get the docstring from.
The first two lines of code worked okay when I ran it. Inside the parenthesis next to input, you could add a question or statement to make it clearer. Whatever you place there will be shown to the user, and the program will wait for them to enter data.

docstring = input('How are you doing today? ')
print('docstring=', docstring)
Think of input as a function in a library. Which, it kinda is.
dir(input)
That will give you a list of functions and attributes you can access. Do you see one that might contain the docstring?
So, try printing that attribute
print(input.__doc__)
What happens?