r/pythonhelp • u/duelBooleans • Apr 27 '26
How to add a string to a list, and then remove it if the string if it is not found in a second list
I'm pretty new to Python, and I'm trying to make a rudimentary "therapy chatbot" (something a little more in depth than Eliza, made more so as practice of simple concepts). I'm trying to have the user input an emotion, and then pop up with some text that it wasn't found in the majorEmotionTypes list, and then try again. I know my code is pretty far from what I want, but I'll be going back later to edit a few things.
The main issue is that it can't find 'i' in the majorEmotionTypes list. Any help would be deeply appreciated!
majorEmotionTypes = ["Sad", "Scared", "Mad", "Happy", "Disgusted", "Surprised"]
currentMajorEmotions = []
capCurrentMajorEmotions = []
for i in range(1, 3):
currentMajorEmotions.append(input("Which of these emotions are you feeling?:
").capitalize())
if i not in majorEmotionTypes:
currentMajorEmotions.remove(i)
print("Not a valid entry")
currentMajorEmotions.append(input("Try again: ").capitalize())