Get startedGet started for free

Reviewing your co-worker's code

Your co-worker is asking you to review some code that they've written and give them some tips on how to get it ready for production. You know that having a docstring is considered best practice for maintainable, reusable functions, so as a sanity check you decide to use this has_docstring() function on all of their functions.

def has_docstring(func):
  """Check to see if the function 
  `func` has a docstring.

  Args:
    func (callable): A function.

  Returns:
    bool
  """
  return func.__doc__ is not None

This exercise is part of the course

Writing Functions in Python

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Call has_docstring() on the load_and_plot_data() function
ok = has_docstring(____)

if not ok:
  print("load_and_plot_data() doesn't have a docstring!")
else:
  print("load_and_plot_data() looks ok")
Edit and Run Code