list1=['A','B']
list2=[1,2,3]
How do I make it so the output shows all possible combinations in this order and without any brackets?
A1
A2
A3
B1
B2
B3
list1=['A','B']
list2=[1,2,3]
How do I make it so the output shows all possible combinations in this order and without any brackets?
A1
A2
A3
B1
B2
B3
You can use itertools.product
:
from itertools import product
list1 = ['A', 'B']
list2 = [1, 2, 3]
for e1,e2 in product(list1, list2):
print(e1+str(e2))
Output:
A1
A2
A3
B1
B2
B3
You may use:
list3 = [a+b for a in list1 for b in map(str, list2)]
print(*list3, sep = "\n")
A1
A2
A3
B1
B2
B3
You can use:
list1 = ['A', 'B']
list2 = [1, 2, 3]
for i in list1:
for j in list2:
print(i+str(j))