Home>

When I wrote the code in the study book, an error occurred and I want to solve it.

Error message: NameError: name'prompt' is not defined
Corresponding source code
Source code:
class Pityna:
    def __init __ (self, name):
        self.name = name
        self.responder = Responder ('Repeat')
    def dialogue (self, input):
        return self.responder.response (input)
    def get_responder_name (self):
        return self.responder.name
    def get_name (self):
        return self.name
class Responder:
    def __init __ (self, name):
        self.name = name
    def response (self, input):
        What is return'{}'. format (input)
    def prompt (obj):
        return obj.get_name () +':' + obj.get_responder_name () +'>'
print ('Pytyna System prototype: pityna')
pityna = Pityna ('Pityna')

while True:
    inputs = input ('>')
    if not inputs:
        print ('bye bye')
        break
    else: else:
        response = pityna.dialogue (inputs)
        print (prompt (pityna), response)
What I tried

Please describe here what you have tried for the problem.
I know that the error message prpmpt is not defined, but
def prompt (obj):
return obj.get_name () +':' + obj.get_responder_name () +'>'
I don't think it's defined here.
It is not well understood.

Supplementary information (FW/tool version, etc.)

Please provide more detailed information here.
The editor is Spyder.