What is the correct way to write a doctest?

  • A
    def sum(a, b):
    “””
    sum(4, 3)
    7
    sum(-4, 5)
    1
    “””
    return a + b
  • B
    def sum(a, b):
    “””
    >>> sum(4, 3)
    7
    >>> sum(-4, 5)
    1
    “””
    return a + b
  • C
    def sum(a, b):
    “””
    # >>> sum(4, 3)
    # 7
    # >>> sum(-4, 5)
    # 1
    “””
    return a + b
  • D
    def sum(a, b):
    ###
    >>> sum(4, 3)
    7
    >>> sum(-4, 5)
    1
    ###
    return a + b
Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

Leave a Comment

Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

Send this to a friend