Permalink
Cannot retrieve contributors at this time
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?
Eugene-Chatbot/rari3.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
34 lines (26 sloc)
1.02 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |