我有一个清单。我想通过为每个元素添加一个共同点来重复这些元素。
main_list = ['lst1','lst2','lst3'] # existing list
new_list = ['lst1_mean','lst1_std','lst2_mean','lst2_std','lst3_mean','lst3_std'] # expected list
我的代码:
aux_list1 = [i+'_mean' for i in main_list]
aux_list2 = [i+'_std' for i in main_list]
new_list = [i,j for i,j in zip(aux_list1,aux_list2)]
有更好的方法吗?
守着星空守着你
相关分类