Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8380183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:23:23+00:00 2026-06-09T16:23:23+00:00

So I wrote a short and simple chat bot in Python, however there’s an

  • 0

So I wrote a short and simple chat bot in Python, however there’s an irritating issue. The program will only call the posResponses() function initially.

In context, if I respond to its initial question with ‘sad’, ‘terrible’ or even ‘asdfasdfasdf’ I will still get a positive response.

What should happen is if I input a negative/ambiguous keyword the negResponses()/ambiguousResponses() function should be called. That is not the case. What did I do wrong, and how do I fix it? Code is as follows:

import random
import time

def opening():
    print('Hello!')

def responseType():
    responseType = str(input('How are you ?'))
    if responseType == 'good' or 'great' or 'fantastic' or 'decent' or 'fine' or 'ok' or 'okay': posResponses()
    elif responseType == 'bad' or 'terrible' or 'sad' or 'grumpy' or 'angry' or 'irritated' or 'tired': negResponses()
    else: ambiguousResponses()

def posResponses():
    number = random.randint(1, 4)
    if number == 1:
        print('That\'s great! So what\'s up?')
        input()
        ambiguousResponses()
    if number == 2:
        print('Really? I\'d like to hear more.')
        input()
        ambiguousResponses()        
    if number == 3:
        print('I\'m glad to hear that. What\'s going on?')
        input()
        ambiguousResponses()        
    if number == 4:
        print('Ah, me too. You should begin a topic discussion.')
        input()
        ambiguousResponses()        

def negResponses():
    number2 = random.randint(5, 8)
    if number2 == 5:
        print('That\'s really too bad. Care to elaborate?')
        input()
        ambiguousResponses()
    if number2 == 6:
        print('Awww. Why?')
        input()
        ambiguousResponses()
    if number2 == 7:
        print('That sucks! How come?')
        input()
        ambiguousResponses()
    if number2 == 8:
        print('What a shame! You should explain why.')
        input()
        ambiguousResponses()

def ambiguousResponses():
    number = random.randint(1, 4)
    if number == 1:
        print('Interesting. Carry on.')
        input()
        ambiguousResponses()
    if number == 2:
        print('Wow, elaborate!')
        input()
        ambiguousResponses()
    if number == 3:
        print('What an astute remark! Continue.')
        input()
        ambiguousResponses()
    if number == 4:
        print('How interesting. Please do explain further.')
        input()
        ambiguousResponses()


if __name__ == "__main__":
    opening()
    responseType()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T16:23:24+00:00Added an answer on June 9, 2026 at 4:23 pm

    Python is parsing it like this:

    if (responseType == 'good') or 'great' or 'fantastic' or 'decent' or 'fine' or 'ok' or 'okay': posResponses()
    elif (responseType == 'bad') or 'terrible' or 'sad' or 'grumpy' or 'angry' or 'irritated' or 'tired': negResponses()
    else: ambiguousResponses()
    

    'great' is a truthy value, so that if statement always succeeds. You probably want to rewrite it like:

    if responseType == 'good' or responseType == 'great' or responseType == 'fantastic' or responseType == 'decent' or responseType == 'fine' or responseType == 'ok' or responseType == 'okay':
        posResponses()
    elif responseType == 'bad' or responseType == 'terrible' or responseType == 'sad' or responseType == 'grumpy' or responseType == 'angry' or responseType == 'irritated' or responseType == 'tired':
        negResponses()
    else:
        ambiguousResponses()
    

    Or, preferably:

    if responseType in {'good', 'great', 'fantastic', 'decent', 'fine', 'ok', 'okay'}:
        posResponses()
    elif responseType in {'bad', 'terrible', 'sad', 'grumpy', 'angry', 'irritated', 'tired'}:
        negResponses()
    

    You could even move those responses into a constant:

    # near the top of the file:
    GOOD_RESPONSES = {'good', 'great', 'fantastic', 'decent', 'fine', 'ok', 'okay'}
    BAD_RESPONSES = {'bad', 'terrible', 'sad', 'grumpy', 'angry', 'irritated', 'tired'}
    
    # when you need to judge a response:
    if responseType in GOOD_RESPONSES:
        posResponses()
    elif responseType in BAD_RESPONSES:
        negResponses()
    else:
        ambiguousResponses()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a very short program that parses a program using python and converts
I wrote this short program which has a tiny GUI. Its supposed to allow
Is there a simple way (short of sticking fwrites after every line) of getting
Here's a simple validation attribute I wrote to enforce number-only strings (I use it
i wrote a simple program to sort numbers one by one for their repeat
I wrote a short bit of code to simply skip num_lines lines in an
I wrote some sort of console client for a simple application. To be more
To help me better understand lambda I wrote this short snippet that rotates and
I have a short question i have wrote this in java. Old code: class
I'm trying to write a short function that will let me quickly read in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.