Correct representation of doctest for function in Python

  • def sum(a, b):
    # a = 1
    # b = 2
    # sum(a, b) = 3
    return a + b
  • def sum(a, b):
    “””
    a = 1
    b = 2
    sum(a, b) = 3
    “””
    return a + b
  • def sum(a, b):
    “””
    >>> a = 1
    >>> b = 2
    >>> sum(a, b)
    3
    “””
    return a + b
  • def sum(a, b):
    ”’
    a = 1
    b = 2
    sum(a, b) = 3
    ”’
    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