header = ['chr', 'pos', 'ms01e_PI', 'ms01e_PG_al', 'ms02g_PI', 'ms02g_PG_al', 'ms03g_PI', 'ms03g_PG_al', 'ms04h_PI', 'ms04h_PG_al']
I want to convert the above list elements into list of tuples. Like:
sample_list = [('ms01e_PI', 'ms01e_PG_al'), ('ms02g_PI', 'ms02g_PG_al'),
'ms03g_PI', 'ms03g_PG_al'), ('ms04h_PI', 'ms04h_PG_al')]
I am thinking lambda or list comprehension can be used to approach this in a short and comprehensive way.
sample_list = [lambda (x,y): x = a if '_PI' in a for a in header ..]
or,
[(x, y) if '_PI' and '_PG_al' in a for a in header]
any suggestions?