The elegance of python


#1
max_n = len(A) + 1
A.sort()
try:
    oneid = A.index(1)
except:
    return 1
for e, i in enumerate(range(oneid+1, max_n + 1)):
    try:
        if A[i] != e+2:
            return e+2
    except:
        return e+2