Q:

Write a Python program to find the first appearance of the substring "not" and "poor" from a given string, if "not" follows the "poor", replace the whole "not"..."poor" substring with "good". Return the resulting string.

0

Write a Python program to find the first appearance of the substring "not" and "poor" from a given string, if "not" follows the "poor", replace the whole "not"..."poor" substring with "good". Return the resulting string.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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!'))

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now