1
I am starting in python and I would like the result of my execution to be as follows:
[ [ 0 , 1 , 2 ] , [ 3 , 4 , 5 ] , [ 6 , 7 , 8 ] , [ 9 ] ]
[ ’ ∗ ∗ ∗ ∗ ’ , ’∗ ∗ ∗ ∗ ’ , ’ ∗ ∗ ’ ]
But I’m not getting it.
My code is like this:
def g(a, b):
if len(a) < b: return [a]
return [a[:b]] + g(a,b + 1)
print(g(list(range(10)), 3))
print(g("*" * 10, 4))
Could you help me?