0

i was trying to make Telegram bot and in the Chatbot code i have this problem whenever i run it "Unindent does not match any outer indentation level" and i still have no idea how to fix it, i already try to change the symbols and anything

import json
import subprocess as s

class Chatbot():
    def __init__(self, name):
        try:
            memory = open(name+'.json','r')
        except FileNotFoundError:
            memory = open(name+'.json','w')
            memory.write('["Will","Alfredo"]')
            memory.close()
            memory = open(name+'.json','r')
        self.name = name
        self.known = json.load(memory)
        memory.close()
        self.historico = []
        self.phrases = {'hello': 'hello, my name is GiroBot','goodbye':'bye, see you next time!'}

     def listening(self,phrases=None):
         if phrases == None:
             phrases = input('>: ')
         phrases = str(phrases)
         phrases = phrases.lower()
         phrases = phrases.replace('e','eh')
         return phrases

     def thinking(self,phrases):
         if phrases in self.phrases:
             return self.phrases[phrases]
         if phrases == 'learn':
             key = input('Digite a phrases: ')
             resp = input('Digite a response: ')
             self.phrases[key] = resp

that is the code and i have problem with this

 def listening(self,phrases=None): 
                                  ^

there is where i got Unindent does not match any outer indentation level, please help

Simon Mengong
  • 2,625
  • 10
  • 22
Elan JM
  • 1
  • 1
  • 1
  • Edit: your functions `listening` and `thinking` seem to be part of your class `Chatbot`, so they have to be indented as well. – offeltoffel Nov 06 '17 at 08:52
  • python recognizes scope with indentation. So, indent the methods `listening` and `thinking` to same level as `__init__`. – Ahsanul Haque Nov 06 '17 at 08:52
  • You forgot to include the `IndentationError: unindent does not match any outer indentation level` line your code throws. I've duped you to the canonical post on how to handle indentation errors. – Martijn Pieters Nov 06 '17 at 08:54
  • try to paste your code on gist or something like that the comment the link – marlo Nov 06 '17 at 08:54

0 Answers0