import string


def letter_part(n):  # takes quotient and index
    """
    Function to calculate the lettered part for a given number of parts n
    Eg. letter_part(1) = 'a', letter_part(26) = 'z', letter_part(27) = 'az', letter_part(702) = zz  this is the max
    Values for n > 702 return None
    :param n:number of parts
    :return: returns a string of length 1 or 2 ranging from a to zz. Returns None for values greater than zz
    """
    q, i = divmod(n, 26)  # divmod returns quotient and modulus
    if i == 0:  # Fix special case for z, n=26 returns (1,0), but we want (0,25)
        q -= 1
        i = 25  # convert i to index for az string.
    else:
        i -= 1  # convert i to index for az string.
    result = None  # set default result to None
    az = string.ascii_lowercase  # 'abcdefghijklmnopqrstuvwxyz'
    if q == 0:  # quotient is 0, first time through a-z
        result = az[i]  # one letter result, eg. 'a'
    elif 26 >= q >= 1:  # quotient is 1 or more, beyond q=26 we would need three letters.
        result = az[q-1]+az[i]  # two letter result, eg. 'aa'
    elif q > 26:
        pass  # will return default None
    return result