# C. fix_start
# Given a string s, return a string
# Where all occurences of its first char have
# Been changed to '*', does t do not change
# The first char itself.
# E.g. 'babble 'yields 'BA ** le'
# Assume that the string is length 1 or more.
# Hint: s. replace (stra, strb) returns a version of string s
# Where all instances of stra have been replaced by strb.
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
# 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