Сообщество IT-специалистов
Ответы на любые вопросы об IT
Профессиональное развитие в IT
Удаленная работа для IT-специалистов
text = 'sometimes i want delete some from this text' new_text = text.replace('some', "") print(new_text)
import re text = 'sometimes i want delete some from this text some' string = re.sub(r'\ssome$|some\s', '', text) print(string)
'i want some delete some from this text timesome'
r'\ssome$|some\s'
text = 'sometimes i want delete some from this text' res = ' '.join([el for el in text.split(" ") if el != 'some']) print(res)