We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
# without using itertoolsdefcartesian_product(a,b):list1=list(map(int,a.split()))list2=list(map(int,b.split()))result=list((n,m)forninlist1forminlist2)print(*result,end=" ")# end=" " in print function will create the output in one linefirstLine=input()secondLine=input()cartesian_product(firstLine,secondLine)# using itertools# from itertools import product# list1 = list(map(int, input().split()))# list2 = list(map(int, input().split()))# print(*list(product(list1, list2)))
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
itertools.product()
You are viewing a single comment's thread. Return to all comments →