I would like to find the first integer after a given integer that is not in a list of integers, nanIndices. I try
next(x for not (x in nanIndices))
and
next(x for x >0 and x not in nanIndices)
and
next(x for x not in nanIndices)
and get
*** SyntaxError: invalid syntax
in both cases. I then try
next(x for x in range(1,1000) and x not in nanIndices)
and get
*** NameError: name 'x' is not defined
What I particularly don't understand is that
next(x for x in nanIndices)
works fine but
next(x for x not in nanIndices)
gives a syntax error
The suggested solution does not work because it returns an array, not the next integer to satisfy the condition.