Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
the baby chatbot
#6
two things
1. for consistency and for compliance with recommendations in PEP8, rename checkInput to check_input. All other functions are lowercase (as recommended by PEP8)
2. instead of using i as counter, you can use enumerate() function:
def check_input(txt, vocab):
    if txt == "list":
        print("let see baby's word list grow:")
        for i, word in enumerate(vocab, start=1):
            print(f"{i}\t{word}")
 
    elif any(s in txt for s in vocab):
        print(random.choice(vocab))
    else:
        print("i've learned a new thing to say! thank you!")
 
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
the baby chatbot - by ronblue77 - Nov-27-2019, 12:33 PM
RE: the baby chatbot - by buran - Nov-27-2019, 12:36 PM
RE: the baby chatbot - by ronblue77 - Nov-27-2019, 12:54 PM
RE: the baby chatbot - by buran - Nov-27-2019, 01:01 PM
RE: the baby chatbot - by ronblue77 - Nov-27-2019, 03:10 PM
RE: the baby chatbot - by buran - Nov-27-2019, 03:28 PM
RE: the baby chatbot - by ronblue77 - Nov-28-2019, 06:52 AM
RE: the baby chatbot - by buran - Nov-28-2019, 08:34 AM
RE: the baby chatbot - by ronblue77 - Nov-29-2019, 08:34 PM
the baby chat bot version 3 - by ronblue77 - Nov-30-2019, 07:17 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020