I Have a list A:
A=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]
I want to code a function that will return a list of lists B:
B=[[4,5,6],[10,11,12],[16,17,18]]
I tried this:
def listing():
A=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]
ans= [A[i:len(A)] for i in range(0, len(A), 3)]
return ans
But it gives me a very long and incorrect output, how could I fix this?