Reputation: 314
I've written the following code:
from itertools import product
list_A = [int(x) for x in input().split()]
list_B = [int(y) for y in input().split()]
print(list(product(list_A, list_B)))
Sample Input
1 2
3 4
Code Output
[(1, 3), (1, 4), (2, 3), (2, 4)]
How can I make the two brackets disappear and rather get (1, 3), (1, 4), (2, 3), (2, 4)
as output?
Upvotes: 0
Views: 333
Reputation: 774
you can do it like this:
print(str(list(product(list_A, list_B)))[1:-1])
Upvotes: 1
Reputation: 4318
essentially you are asking how to print a list but remove the brackets on the two ends:
l = [(1,2), (3,4)]
print(', '.join(map(str, l)))
output:
(1, 2), (3, 4)
Upvotes: 2