def common_text(stringlist, kind='prefix'):
    """
    For a list of strings find common prefix or suffix, returns None
    if no common substring of kind is not 'prefix' or 'suffix'

    :param stringlist: a list of strings to test
    :param kind: string, either 'prefix' or 'suffix'
    :return:
    """

    substring = stringlist[0]

    if kind == 'prefix':
        # loop around strings in list (except first)
        for _str in stringlist[1:]:
            # while substring is not equal in first and Nth shorten
            while _str[:len(substring)] != substring and len(substring) != 0:
                substring = substring[:len(substring)-1]
            # test for blank string
            if len(substring) == 0:
                break

    elif kind == 'suffix':
        # loop around strings in list (except first)
        for _str in stringlist[1:]:
            # while substring is not equal in first and Nth shorten
            while _str[-len(substring):] != substring and len(substring) != 0:
                substring = substring[1:]
            # test for blank string
            if len(substring) == 0:
                break
    # if prefix or suffix is the same as all in list return None - there
    # is no prefix
    if substring == stringlist[0]:
        return None
    # else return the substring
    else:
        return substring