Nov-27-2019, 12:33 PM
hello all
here is a code of a program of what i call "a baby chat bot" the bot only knows 4 words "mom' "dad" "food" and "hi" the user is suppose to talk to the bot and teach it new words or sentences to say every time you say something new to the bot that he doesn't know yet he will say he had learned something new when you say to the bot something he already knows he will replay randomly from his own knowledge (the words or sentences he already knows)
have fun teaching your baby chat bot to talk :)
here is a code of a program of what i call "a baby chat bot" the bot only knows 4 words "mom' "dad" "food" and "hi" the user is suppose to talk to the bot and teach it new words or sentences to say every time you say something new to the bot that he doesn't know yet he will say he had learned something new when you say to the bot something he already knows he will replay randomly from his own knowledge (the words or sentences he already knows)
have fun teaching your baby chat bot to talk :)
import os import random vocab = ["hi", "mom", "dad", "food"] def checkInput(txt, vocab): if any(s in txt for s in vocab): print(random.choice(vocab)) else: print("i've learned a new thing to say! thank you!") def add(txt): vocab.append(txt) def main(): print("hi! i'm a baby chatbot. please teach me how to talk and what to say:") while True: txt = input("> ") if txt == "end": break checkInput(txt, vocab) # print(a) add(txt) main()