I have two lists say:
list1 = ['a','b','a','b'] l2 =['e','d']
how do I merg into a new list
l3 =['a_e','b_e','a_d',b_d']
Try this way:
list1 = ['a','b','a','b'] l2 =['e','d'] print([el1+'_'+el2 for el2 in l2 for el1 in sorted(set(list1))])
Output:
['a_e', 'b_e', 'a_d', 'b_d']
2.1m questions
2.1m answers
60 comments
57.0k users