I'm trying to build Alexa app, And got this annoying Error, please help!

Please don’t post pictures of text. Especially not photographs of text. Copy your code and paste it between triple back ticks to preserve indentation, like this:

Your code goes here.

From your photo, it looks like your listen() function does not return anything. command is therefore None, which cannot be used with the in keyword.

Sorry, what is the wrong about pics?
the code was like this

def listen():
    with sr.Microphone() as source:
         voice = sr.Recognizer.listen(source)
         command = 
 sr.Recognizer.recognize_google(voice, language= 'en')


def run():
      While True:
              command = listen()
              if 'exit' in command:

Why should I not upload images of code/data/errors when asking a question?

About the code

  • We do not know what is in the variable sr. Could you please show code which sets the variable? If it is a module, which one is it?
  • sr.Recognizer.recognize_google(voice, language= 'en') this should be on the previous line right? Otherwise the code is invalid.
  • command = listen() — Here it looks like you expect the fucntion listen() to return a sensible value but as you defined the function it returns just the default value None.
  • What is the error? I do not see it. Please show the error for exactly the code you show. Show the complete error (all the lines).