assert low < high
for i, (a, b) in enumerate(zip(low, high)):
    if a < b:
        mid = chr((ord(a) + ord(b)) // 2)
if mid != a:
    return low[:i] + mid
else:
    return low[:i + 1] + get_key_str(low[i + 1:], 'z')
return low + get_key_str('a', high[len(low):])
Efficient way of keeping numbers in order