def fix_start(s): # +++your code here+++ # LAB(begin solution) front = s[0] back = s[1:] fixed_back = back.replace(front, ‘*‘) return front + fixed_back
# E. not_bad
# Given a string, find the first appearance of the
# substring ‘not‘ and ‘bad‘. If the ‘bad‘ follows
# the ‘not‘, replace the whole ‘not‘...‘bad‘ substring
# with ‘good‘.
# Return the resulting string.
# So ‘This dinner is not that bad!‘ yields:
# This dinner is good!
def not_bad(s): # +++your code here+++ # LAB(begin solution) n = s.find(‘not‘) b = s.find(‘bad‘) if n != -1 and b != -1 and b > n: s = s[:n] + ‘good‘ + s[b+3:] return s
原文:http://blog.csdn.net/tao_sun/article/details/18743387