I have
A = ['A','B','C','D','E','F','G','H','J']
B= ['a','b','c']
I want to combine the list that ‘a’ is combine with first three element of list A , ‘b’ with the next three and ‘c’ with the last three as shown below
C = ['Aa','Ba','Ca','Db','Eb','Fb','Gc','Hc','Jc,]
how can I go about it in python
>Solution :
As a list comprehension you could do this. Although I suspect there’s a nicer way to do it.
[f"{capital}{B[i//3]}" for i,capital in enumerate(A)]
i will increment by 1 for each letter in A so we can do floor division by 3 to only increment it every 3 iterations of A giving us the correct index of B and just use an f-string to concaninate the strings although capital + B[i//3] works too.