Python Forum
Need help in finishing my scripts
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help in finishing my scripts
#1
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.
Reply
#2
what have you tried? Please, post your code in python tags, full traceback (if any) - in error tags
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Yes.. I tried many ways as per my understanding...
docstring = input()
print('docstring=', docstring)
or
def docstring(a):
"""Documentation String"""
print(doctring.__doc__)
Reply
#4
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.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#5
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)
Reply
#6
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?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Help finishing my Wikipedia page card51shor 8 3,217 Jul-09-2020, 06:14 AM
Last Post: card51shor

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020