Menggabungkan daftar daftar ke daftar tunggal Python
import itertools
a = [['a','b'], ['c']]
print(list(itertools.chain.from_iterable(a)))
Sparkling Sable
import itertools
a = [['a','b'], ['c']]
print(list(itertools.chain.from_iterable(a)))
x = [["a","b"], ["c"]]
result = sum(x, [])
# This combines the lists within the list into a single list
listone = [1,2,3]
listtwo = [4,5,6]
joinedlist = listone + listtwo
x = [["a","b"], ["c"]]
result = sum(x, [])
b = ["a", "b"] + [7, 6]
print(b)
# ['a', 'b', 7, 6]