Plz help I'm stuck

import re
import random

class AlienBot:

potential negative responses

negative_responses = (“no”, “nope”, “nah”, “naw”, “not a chance”, “sorry”)

keywords for exiting the conversation

exit_commands = (“quit”, “pause”, “exit”, “goodbye”, “bye”, “later”)

random starter questions

random_questions = (
"Why are you here? ",
"Are there many humans like you? ",
"What do you consume for sustenance? ",
"Is there intelligent life on this planet? ",
"Does Earth have a leader? ",
"What planets have you visited? ",
"What technology do you have on this planet? "

def init(self):
self.alienbabble = {‘describe_planet_intent’: r’.\syour planet’,
‘answer_why_intent’: r’why\sare.*’,
‘cubed_intent’: r’.cube.(\d+)’

Define .greet() below:

def greet(self):
name= input(‘Hello there what is your name?\n>’)
will_help= input(f"Hi {name}, I’m Etcetera. I’m not from this planet. Will you help me learn about your planet?\n>")
if will_help in self.negative_responses:
print(‘Ok, have a nice Earth day!’)

Define .make_exit() here:

def make_exit(self, reply):
for exit in self.exit_commands:
if exit == reply:
print(“Ok, have a nice Earth day!”)

   return True

Define .chat() next:

def chat(self):
reply= input(random.choice(self.random_questions)).lower()
while not self.make_exit(reply):
reply= input(self.match_reply(reply))

Define .match_reply() below:

def match_reply(self, reply):
for intent,reggex_pattern in self.alienbabble.items():
found_match= re.match(reggex_pattern,reply)
if found_match and intent== ‘describe_planet_intent’:
return self.describe_planet_intent()
elif found_match and intent== ‘answer_why_intent’:
return self.answer_why_intent()
elif found_match and intent == ‘cubed_intent’:
return self.cubed_intent(found_match.groups()[0])
return self.no_match_intent()

Define .describe_planet_intent():

def describe_planet_intent(self):
tuples= ("My planet is a utopia of diverse organisms and species. ","I am from Opidipus, the capital of the Wayward Galaxies. ")
return random.choice(tuples)

Define .answer_why_intent():

def answer_why_intent(self):
tuples5=(“I come in peace.”,
“I am here to collect data on your planetand its inhabitants.”,
“I heard the coffee is good.”)
return random.choice(tuples5)

Define .cubed_intent():

def cubed_intent(self, number):
number= int(number)
cubed_number= number**3
return f’Your number {str(number)} cubed is equal to {str(cubed_number)}’

Define .no_match_intent():

def no_match_intent(self):
tuples2=(“Please tell me more.”,"Tell me more! ","Why do you say that? ",“I see. Can you elaborate?”,“Interesting. Can you tell me more?”,
"I see. How do you think? ",
"How do you think I feel when you say that? ")
return random.choice(tuples2)

Create an instance of AlienBot below:


my bot only describes planet intent, else it only returns no match intent. can anyone tell me where im wrong

Please check the following FAQ for some guidance on asking questions. At least formatting and a link to the problem are needed or it’s very hard for anyone else to help, even if they’re willing.

1 Like

I found the mistake that’s y i didn’t edit my post, but thanks