james-l
2/5/2017 - 9:01 PM

python doc testing and doc document

python doc testing and doc document

def get_column(puzzle, col_num):
    """ (str, int) -> str

    Precondition: 0 <= col_num < number of columns in puzzle

    Return column col_num of puzzle.
    >>> get_column('abcde\nefghi\nijklm\n', 1)
    'bfj'
    """

    puzzle_list = puzzle.strip().split('\n')
    column = ''
    for row in puzzle_list:
        column += row[col_num]

    return column

def reverse(s):
    """ (str) -> str

    Return a reversed copy of s.

    >>> reverse('abc')
    'cba'
    """

    s_reversed = ''
    for ch in s:
        s_reversed = ch + s_reversed

    return s_reversed