Imagin I have three lists like:
l = ['2g_', '3k', '3p']
p = ['3f', '2y_', '4k', 'p']
s = ['12g', 'k_', '3p']
So:
>>> ''.join(i[1]*int(i[0])+i[2:] if i[0].isdigit() else i for i in l)
'gg_kkkppp'
>>> ''.join(i[1]*int(i[0])+i[2:] if i[0].isdigit() else i for i in p)
'fffyy_kkkkp'
>>> ''.join(i[1]*int(i[0])+i[2:] if i[0].isdigit() else i for i in s)
'2gk_ppp'
But what in list s:
2gk_ppp must be ggggggggggggk_ppp
12, but only the first digit of it. What are you trying to accomplish?\w+in this answer to[a-z]