Skip to content
Permalink
master
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
def nutrient(text):
list = ["snickers", "pringles ", "coke", "fries", "hamburger"]
list2 = ["Fat: 24 g; Cholesterol: 9 mg; Sodium: 189 mg; Protein: 7 g",
"Fat: 9 g; Cholesterol: 0 mg; Sodium: 150 mg; Protein: 1 g",
"Fat: 0 g; Cholesterol: 0 mg; Sodium: 4 mg; Protein: 0 g",
"Fat: 15 g; Cholesterol: 0 mg; Sodium: 210 mg; Protein: 3.4 g",
"Fat: 14 g; Cholesterol: 47 mg; Sodium: 414 mg; Protein: 17 g"]
listfound=[]
listfound2=[]
dText = text.split()
found_keyword = 0
savepos=0
for text_keyword in dText:
aux=0
for search_keyword in list:
if search_keyword == text_keyword:
listfound.append(search_keyword)
listfound2.append(list2[aux])
found_keyword += 1
aux+=1
if found_keyword==0:
print("Keyword not found!")
else:
return listfound,listfound2
input = str(input("Type sentance: "))
print(nutrient(input))