fork download
  1. lst = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  2.  
  3. result = [lst[x:x+3] for x in range(0, len(lst), 3)]
  4.  
  5. print(result)
Success #stdin #stdout 0.01s 9992KB
stdin
Standard input is empty
stdout
[[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]]