Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from itertools import product
- list1 = list(input())
- list2 = list(input())
- result = product(list1, list2)
- for item in result:
- print(item, end=" ")
- /Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4 /Users/mona/PycharmProjects/PythonCodes/cartesian_product.py
- 2 4
- 3 5
- ('2', '3') ('2', ' ') ('2', '5') (' ', '3') (' ', ' ') (' ', '5') ('4', '3') ('4', ' ') ('4', '5')
- Process finished with exit code 0
- from itertools import product
- list1 = input().split()
- list2 = input().split()
- result = product(list1, list2)
- for item in result:
- print(item, end=" ")
Advertisement
Add Comment
Please, Sign In to add comment