I have a problem with this part of the assignment.
I try two codes and both have problems:
1.
for word in stopwords:
token = " " + word + " "
sentence = sentence.replace(token, " “)
sentence = sentence.replace(” ", " ")
Error:
Expected Output:
'go store get snack'
My output:
'i go store get snack'
2.
modified_sentence = “”
START CODE HERE
for word in sentence.split(" "):
if word not in stopwords:
modified_sentence = modified_sentence + word + " "
sentence = modified_sentence
My output:
'go store get snack '
For the second response, I have an extra space at the end. Besides, I think it is better to solve it without using extra memory.
Thank you in advance for your help.