itertools.product()

Sort by

recency

|

875 Discussions

|

  • + 0 comments

    from itertools import product A = list(map(int,input().split())) B = list(map(int , input().split())) print(*product(A,B))

  • + 0 comments
    if __name__=='__main__':
        A,B = tuple(map(int,input().split())),tuple(map(int,input().split()))
        
        for x in A:
            for y in B:
                print((x,y),end=' ')
    
  • + 0 comments
    from itertools import product
    lists=[list(map(int,input().split())) for _ in range(2)]
    print(*product(lists[0],lists[1]))
    
  • + 0 comments

    Here another slightly different approach:

    from itertools import product
    
    A = map(int, input().split())
    B = map(int, input().split())
    
    aux = list(product(A,B))
    output = " ".join(str(tup) for tup in aux)
    print(output)
    
  • + 0 comments

    a=list(map(int,input().split())) b=list(map(int,input().split())) for x in a : for y in b: c=(x,y) print(c,end=' ')