1# A Python program to print all
2# combinations of a given length
3from itertools import combinations
4
5# Get all combinations of [1, 2, 3]
6# and length 2
7comb = combinations([1, 2, 3], 2)
8
9# Print the obtained combinations
10for i in list(comb):
11 print (i)
12
1# A Python program to print all
2# permutations of given length
3from itertools import permutations
4
5# Get all permutations of length 2
6# and length 2
7perm = permutations([1, 2, 3], 2)
8
9# Print the obtained permutations
10for i in list(perm):
11 print (i)
12