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?
GroupD3/Greetings.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
18 lines (16 sloc)
499 Bytes
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
#Made by Andris Jansons | |
def isGreeted(text): | |
"""Checks if user greets the program and if the greeting is formal or not""" | |
KEYWORDS_FORMAL = "hi, hello".split(", ") | |
KEYWORDS_UNFORMAL = "hey, heya, aloha, wassup, hola, ola, heyy, sup, yo".split(", ") | |
greeted = False | |
formal = False | |
for word in text: | |
if word in KEYWORDS_FORMAL: | |
formal = True | |
greeted = True | |
break | |
elif word in KEYWORDS_UNFORMAL: | |
greeted = True | |
break | |
return greeted, formal # Both booleans |