请用Python回答~

输入表示自己状态的单词,可以区分幸福还是悲伤,完成并实行这个程序。
▪ ▪ 创建幸福状态单词列表
▪ ▪ 创建悲伤状态单词列表
▪ ▪ 输入表示自己状态的单词
▪ ▪ 输出自己的状态单词是happy还是sad
▪ ▪ 如果是没有状态的单词,请选择happy状态和sad状态添加到列表中
▪ ▪ 保存状态列表到文件


happyWords = ['happy'];
sadWords = ['sad'];


def myIndex(list, value):
    for i in range(len(list)):
        if (list[i] == value):
            return i;
    return -1;

def isHappy():
    inputWord = input("Enter a word: ");
    if (myIndex(happyWords, inputWord) != -1):
        print("The word is happy");
    elif (myIndex(sadWords, inputWord) != -1):
        print("The word is sad");
    else:
        select = input("The word is neither happy nor sad, please select one of the two, A: happy, B: sad:");
        if (select == 'A'):
            happyWords.append(inputWord);
        elif (select == 'B'):
            sadWords.append(inputWord);

while True:
    isHappy();
    select = input("Do you want to continue? Y/N:");
    if (select == 'N'):
        break;
    else:
        continue;

区分幸福还是悲伤是要智能识别还是预定义查询啊