title: how to match multiple user input with text content using python
body: <p>I have a program that allow the user to choose the path of files in order to search for keyword.</p>
  
  <p>The program work perfect when user enter one word but it doesn't display anything when he enter more than 1 word.</p>
  
  <p>where is the error in my function?</p>
  
  <ul>
  <li>x is 1 word user input</li>
  <li>z is more than 1 word</li>
  <li>d in order to create a dictionnary</li>
  </ul>
  
  <h1>code:</h1>
  
  <pre><code>def HighLight(self,x,TextString,RepX):
          thematch=TextString.replace(x,RepX)
          TheCount=TextString.count(x)
          self.textEdit_PDFpreview.insertHtml(str(thematch))
          return thematch     
  
  
  
  def MatchFunc(self):            # Function to highlight the found criteria and display it in the right pane
      self.textEdit_PDFpreview.clear()
      self.x = self.lineEditSearch.text().strip()
      TextString=self.ReadingFileContent(self.FileListSelected())
      self.z = ""
      counter = 0 
      self.d = defaultdict(list)  
      self.filename = os.path.basename(self.FileListSelected())
  
      for counter , myLine in enumerate(self.filename):
          y=list(self.x.split())
          print(y)       
  
          for self.z in y:                
              RepX='&lt;u&gt;&lt;b style="color:#FF0000"&gt;'+self.z+'&lt;/b&gt;&lt;/u&gt;'                
              self.textEdit_PDFpreview.clear()
  
              if self.z in TextString:
                  self.d[self.z].append(counter + 1)                        
                  TextString = self.HighLight(self.z,TextString,RepX)
  
  
              elif self.x in TextString:
                  RepX='&lt;u&gt;&lt;b style="color:#FF0000"&gt;'+self.x+'&lt;/b&gt;&lt;/u&gt;'
                  self.textEdit_PDFpreview.clear()
                  self.d[self.x].append(counter + 1)                                        
                  self.HighLight(self.x,TextString,RepX)
  </code></pre>