Here I'm having the list of list, i want to concatenate only the first two elements if the second element of list has name. else do nothing.
The below is the code which i tried:
lst_1 = [['ANTWERP' 'BRIDGE', '05', 'N'],
['NORTHERN' 'VIGOUR', '05', 'N'],
['BRIDGE', '98', 'N']]
for i in lst_1:
for j in i:
j[0:2] = ['_'.join(j[0:2])]
expected output:
[['ANTWERP_BRIDGE', '05', 'N'],
['NORTHERN_VIGOUR', '05', 'N'],
['BRIDGE', '98', 'N']]
can i find any way to do this?