Hi,
I need some assistance trying to delete elements in list.
Your task is to write a function, called bawdlerize(<sent>, <word>), which removes an unsavory word,
<word>, from a sentence, <sent>. Use the "del" operator on lists for this function. Example:
s = ["now", "is", "the", "time", "for", "all", "good", "men", "to",
"come", "to", "the", "aid", "of", "their", "parties"]
bawdlerize(s, "to")
s = ["now", "is", "the", "time", "for", "all", "good", "men", "come",
"the", "aid", "of", "their", "parties"]
Here is what I did so far
s = list(raw_input("enter the the sentence you want in a list"))
def bawdlerize(s,w):
for i in range(len(s)):
del s[w]
return s
I changed the variables <sent> to s and <word> because for some reason python doesn't accpept < > these angle signs for substitution as variables. I put the list function outside the scope of the raw_input function because raw_input function only accepts strings.
This seems to be an easy problem but I can't seem to figure out what I am doing wrong thanks.