I have two lists, and I need to make a combination of strings from these lists, I tried, but I think this is not very effective for large lists.
data = ['keywords', 'testcases'] data_combination = ['data', 'index'] final_list = [] for val in data: for comb in range(len(data_combination)): if comb == 1: final_list.append([val] + data_combination) else: final_list.append([val, data_combination[comb]])
My way out:
[['keywords', 'data'], ['keywords', 'data', 'index'], ['testcases', 'data'], ['testcases', 'data', 'index']]
Is there any other pythonic way to achieve it?
source share