Answers for "python seperate list into two lists"

4

combining list of list to single list python

import itertools
a = [['a','b'], ['c']]
print(list(itertools.chain.from_iterable(a)))
Posted by: Guest on April-20-2021
-2

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 "python seperate list into two lists"

Python Answers by Framework

Browse Popular Code Answers by Language