Answers for "split list into multiple lists python"

0

split list into multiple lists python

def split_list(a_list, number):
    splitNumber = len(a_list) // number
    result = [a_list[x:x+splitNumber] for x in range(0, len(a_list), splitNumber)]
    if(len(result) > number):
      result[len(result) - 2] = result[len(result) - 2]+ result[len(result)-1]
      result.pop()
    return result

a = [i for i in range(11)]
print(split_list(a,3))
Posted by: Guest on August-01-2021

Code answers related to "split list into multiple lists python"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language