均分Python列表两个函数

def splitlist(biglist,number):
    """number是要分成的份数"""
    retlist=[]
    listlen=len(biglist)
    everyamounts=listlen//number
    slicelist=[]
    for i in range(number):
        start=i*everyamounts
        end=(i+1)*everyamounts
        if i==(number-1):          # 加这句是让最后的列表把剩余的也包括进去。
            end=listlen
        slicelist=biglist[start:end]
        retlist.append(slicelist)
    return retlist


def splitlist2(biglist,number):
    retlist=[]
    listlen=len(biglist)
    everyamounts=listlen//number
    slicelist=[]
    for i in range(number):
        start=i*everyamounts
        end=(i+1)*everyamounts
        slicelist=biglist[start:end]
        retlist.append(slicelist)
    if end<listlen:              # 把剩余的形成一个列表。
        slicelist=biglist[end:listlen]
        retlist.append(slicelist)
        
    return retlist



alist=[3,2,7,6,8,9,10,"a","b","abd",0,3,77,9,6,888,678]
s=splitlist(alist,3)
print(s)