def index_satisfying(iterable, condition):
 for (i, x) in enumerate(iterable):
  if condition(x):
   return i
 try:
  return (i + 1)
 except NameError:
  raise ValueError('iterable must be non-empty')

def index_satisfying ( iterable , condition ) : for ( i , x ) in enumerate ( iterable ) : if condition ( x ) : return i try : return ( i + 1 ) except NameError : raise ValueError ( 'iterable must be non-empty' )
returns the index of the first element in iterable that satisfies the given condition .