简体   繁体   中英

How can I remove parentheses (both side) from tuple?

This is my script.py:

from itertools import product
A = input().split()
B = input().split()
li1 = []
li2 = []
for i in A:
    li1.append(int(i))
for j in B:
    li2.append(int(j))

result = product(li1,li2)
print(tuple(result))

it gives me result like this ((1, 3), (1, 4), (2, 3), (2, 4))

But I want to result like this (1, 3) (1, 4) (2, 3) (2, 4)

How can I do this?

Unpack with a *

print(*result)

This will use the contents of the iterable as arguments to print() , instead of the whole thing as a single argument.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM