I have a list, a:
a
a = [\'a\',\'b\',\'c\']
and need to duplicate some values with the suffix _ind added this way (
_ind
You can use itertools.chain():
itertools.chain()
import itertools l = ['a','b','c'] new_list = list(itertools.chain.from_iterable([[i, i+"_ind"] for i in l])) print new_list
Output:
['a', 'a_ind', 'b', 'b_ind', 'c', 'c_ind']