Skip to content
Permalink
4fe508669c
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
24 lines (20 sloc) 1.04 KB
# Made by Andris Jansons
KEYWORDS = "the, a, an, get, good, best, is, are, to, nice, pleasant, lovely, cool, fine, stupid, goddamn, great, large, small, medium, new, newest, old, closest, smallest, biggest, coolest".split(", ")
def findFood(text):
"""Finds food after special KEYWORDS"""
found = False
food = ""
for word in text:
if found == False:
if word in KEYWORDS:
found = True #Finds the first keyword
food = word
else:
if word in KEYWORDS:
food = food + " " + word
continue
food = food + " " + word #If multiple keywords follow each other
break # take all of them in account and the word
# that follows them as well e.g. "The best burger"
food = food.replace("get",'').replace("is",'').replace("are",'').replace("to",'').strip(' ') # Make the string neat for printing it out
return food