python nested for loop when index of outer loop equals to length of inner loop you start again

I have

A = ['A','B','C','D','E','F','G','H']
B= ['a','b']

want to iterate through the list to get

C = ['Aa','Bb','Ca','Db','Ea','Fb','Ga','Hb']

how can I go about it in python

>Solution :

You can do this by using the index in the A list mapped on the number of elements in the B list with the modulo operation (%) :

A = [1,2,3,4,5,6,7,8]
B= ['a','b']
C = []

for i in range(len(A)):

Leave a Reply