Reputation: 7536
Given the following lists:
A=['a','b','c']
B=[1,2]
I'd like to join the values such that each element of B is joined to each of A like this:
['a1','a2','b1','b2','c1','c2']
Thanks in advance!
Upvotes: 0
Views: 176
Reputation: 6299
A=['a','b','c']
B=[1,2]
C = []
for a in A:
for b in B:
C.append( str(a) + str(b) )
print(C)
Result:
['a1', 'a2', 'b1', 'b2', 'c1', 'c2']
Upvotes: 1