def table(listOfDicts):
    """Loop through a list of dicts and return a markdown table as a multi-line string.

        listOfDicts -- A list of dictionaries, each dict is a row
        """
    markdowntable = ''
    markdownheader = '| ' + ' | '.join(map(str, listOfDicts[0].keys())) + ' |'
    markdownheaderseparator = '|-----' * len(listOfDicts[0].keys()) + '|'
    markdowntable += markdownheader + '\n'
    markdowntable += markdownheaderseparator + '\n'
    for row in listOfDicts:
        markdownrow = ''
        for key, col in row.items():
            markdownrow += '| ' + str(col) + ' '
        markdowntable += markdownrow + '|' + '\n'
    return markdowntable
