Concatenating Strings: “Multiplication” of two list of strings
问题 For list of strings, define the multiplication operation in as concatenating here: l1 = ['aa', 'bb', 'cc'] l2 = ['11', '22'] l3 = l1 op l2 Expected output: l3 = ['aa11', 'aa22', 'bb11', 'bb22', 'cc11', 'cc22'] Simply we can use for l in l1: for ll in l2: l3.append(l+ll) But I'd be grateful to hear a pythonic solution. 回答1: from itertools import product l1 = ['aa', 'bb', 'cc'] l2 = ['11', '22'] l3 = [x+y for (x,y) in product(l1,l2)] print(l3) But it's effectively the same thing as what you're