I'm creating a simple chatbot working with random.choice() of possible responses to possible comments.
I would like to know how to work with dictionaries instead of return. And whether this ould be more advantageous for my code:
def create_response(self, menss, first_message):
if first_message == menssin ('ok'):
return random.choice(['Ok'])
if menss == menss in ('hi'.lower(), 'hello'.lower(),
return random.choice(['Hi', 'Hello', 'Helloo'])
elif menss == menss in ('Y?'.lower(), 'Wbu?'.lower()):
return random.choice(['No.', 'Nop.'])