sentence = ['she sells sea shells by the sea shore']
Заранее спасибо за помощь.
sentence = ['she sells sea shells by the sea shore']
>>> sentence = 'she sells sea shells by the sea shore' >>> out = ' '.join(map(lambda x: 'like ' + x if len(x) > 1 and x[:2] == 'sh' else x, sentence.split(" "))) >>> print(out) like she sells sea like shells by the sea like shore
len(x) > 1 and x[:2] == 'sh'
x.startswith('sh')
import re sentence = 'she sells sea shells by the sea shore' out = re.sub(r'\bsh', 'like sh', sentence)