Programming/python
python from itertools import product
RosyPark
2019. 10. 7. 22:45
0. python from itertools import product
- 길이 3이니깐 3^2 = 9
- 길이는 9개
- 두개 이상의 리스트에서 모든 조합을 구하는 방법
1
2
3
4
5
6
7
|
from itertools import product
example = [['x'],['a','b',],['1','2','3']]
result = list(product(example, example))
len_result = len(result)
print(result)
#[(['x'], ['x']), (['x'], ['a', 'b']), (['x'], ['1', '2', '3']), (['a', 'b'], ['x']), (['a', 'b'], ['a', 'b']), (['a', 'b'], ['1', '2', '3']), (['1', '2', '3'], ['x']), (['1', '2', '3'], ['a', 'b']), (['1', '2', '3'], ['1', '2', '3'])]
print(len_result) #9
|
cs |