Why Bot message is not printing? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why Bot message is not printing?

import random from random import choice class chatbot: #gives message according to the users analyzed message bot_greetings = ["Hola","Hey bro","hello","hey"] def __init__(self,analyze_message): self.analyze_message = analyze_message def chat_message(self): if self.analyze_message == True: bot_message = random.choice(bot_greetings) print('"_":'+bot_message) else: print("Sorry Man I can't analyze your last message") class user: #analyze user message def __init__(self,user_input): #self.user_input = user_input pass def analyze_message(self): user_greetings = ["hi","hello","hey","Hey bro"] if self.user_input in user_greetings: return True else: return False signal = analyze_message chatbot(signal) class chat_interface: #the whole chat interface will be shown by this class user_input = input('user:') user_message = user(user_input) def main(): chat_interface() if __name__ == '__main__': main()

6th Jul 2018, 6:55 AM
IMRAN HOSEN
IMRAN HOSEN - avatar
2 Answers
+ 4
from random import choice class chatbot: bot_greetings = ["Hola","Hey bro","hello","hey"] def __init__(self,analyze_message): self.analyze_message = analyze_message self.chat_message() def chat_message(self): if self.analyze_message == True: bot_message = choice(chatbot.bot_greetings) print('"_":'+bot_message) else: print("Sorry Man I can't analyze your last message") class user: def __init__(self,user_input): self.user_input = user_input chatbot(self.analyze_message()) def analyze_message(self): user_greetings = ["hi","hello","hey","Hey bro"] if self.user_input in user_greetings: return True return False class chat_interface: user_input = input('user:') user_message = user(user_input) def main(): chat_interface() if __name__ == '__main__': main()
6th Jul 2018, 6:45 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 2
please put the code to code playground and give the link. i cant copy paste those code from android
6th Jul 2018, 1:41 PM
Kevin AS
Kevin AS - avatar