create n sublists python

Solutions on MaxInterview for create n sublists python by the best coders in the world

showing results for - "create n sublists python"
Kellan
30 May 2020
1def sublist(lst, n):
2    sub=[] ; result=[]
3    for i in lst:
4        sub+=[i]
5        if len(sub)==n: result+=[sub] ; sub=[]
6    if sub: result+=[sub]
7    return result
similar questions
queries leading to this page
create n sublists python