Siema
Może mi ktoś wyjaśnić to zadanie? Mam napisać program który sprawdzi czy w podanym stringu znajdują się słowa 'not' i 'poor' i jesli 'not' następuje po 'poor' to mam zamienić 'not ... poor' na 'good' i zwrócić wyniki ciągu. Z góry dzięki
def not_poor(str1):
snot = str1.find('not')
spoor = str1.find('poor')
if spoor > snot and snot>0 and spoor>0:
str1 = str1.replace(str1[snot:(spoor+4)], 'good')
return str1
else:
return str1
print(not_poor('The lyrics is not that poor!'))
print(not_poor('The lyrics is poor!'))