code: def sliding_window(seq, lookahead):
      
      it = itertools.chain(iter(seq), ' ' * lookahead)  # Padded iterator
      window_size = lookahead + 1
      result = tuple(itertools.islice(it, window_size))
      if len(result) == window_size:
          yield result
      for elem in it:
          result = result[1:] + (elem,)
          yield result
docs: Create a sliding window with the specified number of lookahead characters.