Apparently, my string recognition algorithm is not working properly. It is returning the wrong responses based on the user's input. I know it's probably something simple, but I just can't see what it is right now. I done the research and I haven't found another python issue here where when the user input is entered, the wrong response is returned. Are my if statements properly formed? Is there an issue with the string search?
import random
def po_response():
response = {1 : 'This is random response A from po_response()',
2 : 'This is random response B from po_response()',
3 : 'This is randomw response C from po_response()'}
answer = random.sample(response.items(),1)
print(answer)
main()
def greetings_response():
response = {1 : 'This is response A from greetings_response()',
2 : 'This is response B from greetings_response()',
3 : 'This is response C from greetings_response()'}
answer = random.sample(response.items(),1)
print(answer)
return response
main()
def main():
userRequest = input('Welcome, Please enter your request. \n')
userReq = userRequest.lower()
if 'how are you' or 'how\'s it going' in userReq:
print('first if')
print('The value of the input is ')
print(userReq)
greetings_response()
elif 'ship' + 'po' or 'purchase order' in userReq:
print('elif')
print('The value of the input is ')
print(userReq)
po_response()
else:
print('Please re-enter your request')
main()
Here is the response I get when I enter 'ship po'
Welcome, Please enter your request.
>>>ship po
first if
The value of the input is
ship po
[(2, 'This is response B from greetings_response()')]
It should not go to the greetings_response() function, it should go to the po_response() function. Not sure why it's acting this way.