fork(1) download
  1. from itertools import islice
  2.  
  3. x = [23, 25, 3, 45, 67, 89, 67, 45, 4, 6]
  4. y = []
  5. seq = iter(x)
  6. while sublist := list(islice(seq, 0, len(y) + 1)):
  7. y.append(sublist)
  8. print(y)
Success #stdin #stdout 0.03s 9608KB
stdin
Standard input is empty
stdout
[[23], [25, 3], [45, 67, 89], [67, 45, 4, 6]]