Cartesian product of two lists in python [duplicate]

Do a list comprehension, iterate over both the lists and add the strings, like

list3 = [i+str(j) for i in list1 for j in list2]

Leave a Comment