Contact: aviboots(AT)netvision.net.il
39,861 questions
51,782 answers
573 users
from itertools import product lst = [1, 2, 3] print(list(product(lst, repeat = 2))) ''' run: [(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3), (3, 1), (3, 2), (3, 3)] '''
from itertools import product s = 'abc' print(list(product(s, repeat = 2))) ''' run: [('a', 'a'), ('a', 'b'), ('a', 'c'), ('b', 'a'), ('b', 'b'), ('b', 'c'), ('c', 'a'),('c', 'b'), ('c', 'c')] '''