I'm trying to build an AI you teach and you ask questions and if it doesn't know it will ask you and puts an answer to go with it, I just cant get it to have multiple answers to one question.
I've kinda tried nested lists but choosing one randomly comes difficult and i don't think it was nested right.
quest=[]
ans=[]
loop=0
newword=['Oh, I dont know this!','Hmm Ive never heard of that.','idk','owo whats this?','Im still learning.']
running=True
while running==True:
a=input('Ask a question')
if a in quest:
while loop<=len(quest):
if a==quest[loop]:
print(ans[loop])
break
else:
loop=loop+1
else:
quest.append(a)
b=input(newword[randint(0,4)]+' You tell me, '+a)
ans.append(b)
'b' is answer given from a question to the user. In the if statement above it just checks if the question asked is already in a list. 'a' represents the question asked.
If i ask 'How are you doing?' it adds it to a question list and asks me in return. with time it i want it to have more than one answer to this question. so it will randomly pick from either good, or bad, ect... i have the questions in a loop. i just need to pair multiple answers with each question.
class
,namedtuple
, ordict
to solve this but I would need a better example. Please provide a few inputs and the output you expect for those inputs.