def nth(n, seq):
 if isinstance(seq, (tuple, list, collections.Sequence)):
  return seq[n]
 else:
  return next(itertools.islice(seq, n, None))

def nth ( n , seq ) : if isinstance ( seq , ( tuple , list , collections . Sequence ) ) : return seq [ n ] else : return next ( itertools . islice ( seq , n , None ) )
the nth element in a sequence .