itertools.product()

Sort by

recency

|

863 Discussions

|

  • + 0 comments
    from itertools import product
    A=list(map(int,input().split()))
    B=list(map(int,input().split()))
    
    p=sorted(product(A,B))
    for i in p:
            print(i,end=" ")
    
  • + 0 comments

    For Python3

    import itertools
    
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    
    print(*itertools.product(A, B))
    
  • + 1 comment
    # My solution is to create a list of integers out of each line of input, make a list out of their product and finally print the elements of that list separated by a single space.
    from itertools import product
    
    A = input().split()
    A = [int(x) for x in A]
    B = input().split()
    B = [int(x) for x in B]
    C = list(product(A, B))
    for x in C:
        print(x, end=" ")
    
  • + 0 comments

    from itertools import product

    a_ = input().split() b_ = input().split()

    xd_ = list(map(lambda x: tuple(int(elem) for elem in x),list(product(a_, b_)))) print(str(xd_).replace("[", "").replace("]", "").replace("),", ")"))

  • + 0 comments

    A Clear & Understandable Snippet

    from itertools import product

    a=input().split() b=input().split() lst=[] for i in a: if i.isdigit: lst.append(int(i))

    lst2=[] for j in b: if j.isdigit: lst2.append(int(j))

    a=list(product(lst,lst2))

    for x in a: print(x,end=' ')