itertools.product()

  • + 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=" ")