*IM KINDA NEW TO PYTHON*
Down here are my orders for this one, I am allowed to ask anyone for this, this is not an assignment to post but just something
we were given to understand, and I really dont know why doesnt it work, and I open it via cmd and everytime theres the eror message it just closes right away so I don't have a chance to read it
can anyone help me figure out?
# 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):
string = raw_input("Enter a string")
bad = 'bad'
notstring = 'not'
badfind = string.find(bad)
notfind = string.find(notstring)
substringend = badfind + bad(length)
substring = string[notfind:(substringend+1):1]
if (badfind > notfind):
string.replace(string, substring, 'good')
return string
Down here are my orders for this one, I am allowed to ask anyone for this, this is not an assignment to post but just something
we were given to understand, and I really dont know why doesnt it work, and I open it via cmd and everytime theres the eror message it just closes right away so I don't have a chance to read it
can anyone help me figure out?
# 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):
string = raw_input("Enter a string")
bad = 'bad'
notstring = 'not'
badfind = string.find(bad)
notfind = string.find(notstring)
substringend = badfind + bad(length)
substring = string[notfind:(substringend+1):1]
if (badfind > notfind):
string.replace(string, substring, 'good')
return string