fork download
  1. # your code goes here
  2. def g(a, b):
  3. if len(a) < b: return [a]
  4. return [a[:b]] + g(a[b:], b)
  5.  
  6.  
  7. print(g(list(range(10)), 3))
  8. print(g("*" * 10, 4))
Success #stdin #stdout 0.02s 9220KB
stdin
Standard input is empty
stdout
[[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]]
['****', '****', '**']