1. Learn
  2. /
  3. Courses
  4. /
  5. Intermediate Python for Developers

Connected

Exercise

Single-line docstrings

Docstrings are used to explain the purpose of a function. While the function name should be descriptive, this needs to be balanced with the length of the function name, so docstrings allow you to provide more detail.

In this exercise, you'll take the previously created calculate_discount() function and add a single-line docstring.

Instructions

100 XP
  • Add a docstring stating """Calculate the discounted price of a product.""".
  • Access the function's docstring using the appropriate attribute.