title: Trying to make python open a program via voice command
body: <p>I'm trying to make something close to Alexa so I can have more liberty in making the commands and what they do. But I'm stuck on this error and can't figure why it doesn't remove the spaces from the string</p>
  <pre><code>listener = sr.Recognizer()
      engine = pyttsx3.init()
      voices = engine.getProperty('voices')
      engine.setProperty('voice', voices[1].id)
      
      programs = {
                  'brave': 'brave.exe',
                  'Chrome': 'chrome.exe',
                  }
          
          def run_program(program):
                  try:
                      spaces = int(program.count(' '))
                      print(spaces)
                      program.replace(' ', '', spaces)
                      print(program)
                      os.startfile(f&quot;{programs[program]}&quot;)
                  except Exception as er:
                      print(er)
                      talk(&quot;that program isn't in the list&quot;)
          def talk( text):
                  engine.say(text)
                  engine.runAndWait()
  </code></pre>
  <p>output:
  <a href="https://i.stack.imgur.com/EqDMB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EqDMB.png" alt="enter image description here" /></a></p>