def direction_code(direction):
    """Obtain the integer code of a direction string.

    Args:
        direction (str): *forward* or *backward*

    Returns:
        int: direction code
    """
    if direction == 'backward':
        return 2
    return 1
