Suppose I have two lists:
t1 = ["abc","def","ghi"]
t2 = [1,2,3]
How can I merge it using python so that output list will be:
t = [("abc",1),("def",2),("ghi",3)]
The program that I have tried is:
t1 = ["abc","def"]
t2 = [1,2]
t = [ ]
for a in t1:
for b in t2:
t.append((a,b))
print t
Output is:
[('abc', 1), ('abc', 2), ('def', 1), ('def', 2)]
I don't want repeated entries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With