[python list] ํ์ด์ฌ ๋ฆฌ์คํธ ์ ๋ฆฌ์คํธ ํผ์น๊ธฐ_how to flatten a list of lists in python
#ํ์ด์ฌ ๋ฆฌ์คํธ ํผ์น๊ธฐ #ํ์ด์ฌ 2d ๋ฆฌ์คํธ ํผ์น๊ธฐ #python 2d list flatten #python nested list flatten ๋ค์๊ณผ ๊ฐ์ด 2D list๋ฅผ 1D list๋ก ์ ํํ๋ ๋ฐฉ์์ 'flattening'์ด๋ผ๊ณ ํ๋ค 1. itertools์ chain ํจ์ ์ฌ์ฉํ๊ธฐ import itertools List_2D = [['a','b','c'],[1,2,3],['d',4,'e']] #List to be flattened List_flat = list(itertools.chain(*List_2D)) print("Original List:",List_2D) print("Flattened List:",List_flat) # print๋ฌธ ์ถ๋ ฅ๊ฒฐ๊ณผ # Original List: [['a', 'b..