Here’s a very basic solution:
list = ['BHX', 'AR', 'DEFab', 'ABR', 'DEFyr', 'HYt', 'wqw', 'DEF-a']
merged_list = []
current=""
for s in list:
if s.startswith('DEF'):
merged_list.append(current + ' ' + s)
current=""
else:
current += s
1
solved Merging elements in a list until certain text appears