Tsallaka zuwa abun ciki
Justice Tech School

Comments and Docstrings

Comments start with #. A docstring is a string at the top of a function, class or module and is read by help().

Example
def area(w, h):
    """Return the area of a rectangle."""
    return w * h  # simple multiply

print(area(3, 4))
print(area.__doc__)

Result

12
Return the area of a rectangle.

Exercise

Start a comment.

 note

Quiz Test

Where does a docstring go?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.