Example Function Structure

All functions should have a triple-quoted comment directly under the def line. This comment should describe what the function does, what the parameters are, and what the function returns.

Here are two examples of well-defined functions:

def letter_count(letter,text):
    """
    Purpose: count how many of given letter are in text
    Parameters:  letter -- a single letter from the alphabet
                 text -- a string
    Returns: integer count
    """
    count = 0
    for i in range(len(text)):
        if text[i] == letter:
            count = count + 1
    return count


def print_rules():
    """
    Purpose: To display the game rules.
    Parameters:  None
    Side effect: Prints the rules to the screen
    Returns: None
    """
    print("Welcome to the game of life!")
    print("Here are the rules: ")
    print("Rule #1: be nice to others")
    print("Rule #2: don't give up")
    print("Rule #3: do your best")
    return