I have the following code I made. It works great but problems arise when I add sentences with commas, full-stops etc. I've researched and can see strip() as a potential option to fix it? I can't see where to add it and have tried but just error after error!
Thanks
sent_analysis = {"beer": 10, "wine":13,"spirit": 11,"cider":16,"shot":16}
def sentiment_analysis(dic, text):
split_text = text.split()
result = 0.00
for i in split_text:
if i in dic:
result+= dic[i]
return result
print sentiment_analysis(sent_analysis,"the beer, wine and cider were great")
print sentiment_analysis(sent_analysis,"the beer and the wine were great")