title: how to run infinite while loop until it finds the value in Python?
body: <p>I am relatively new to Python and learning with fun so far.</p>
  
  <p>What I am trying to do is finding the position of button using Python and its library, Pyautogui.</p>
  
  <p>Here is my code.</p>
  
  <pre><code>import webbrowser, pyautogui, time, datetime
  
  class workDoneClicker:
  
      def buttonTrack(self):
          global x, y
          x = ()
          y = ()
          while x == ():
              coordinate = pyautogui.locateOnScreen('image.png')
              x, y = (coordinate[0], coordinate[1])
              return x, y
  
      def clicker(self):         
  
          if pyautogui.alert(text="hi", title="hi") == 'OK':
              webbrowser.open('http://example.com')
              time.sleep(3)
              self.buttonTrack()
              self.clickButton()
              print("executed")
  
          else:
             print("not executed")
  </code></pre>
  
  <p>What I want to do is to execute the buttonTrack function until it finds the value, and return x, y. <br>
  And run the next code in clicker function.<br>
  Getting the value using buttonTrack function takes some seconds since it has to load a webpage.<br>
  But when I run the code clicker, it seems that it doesn't do infinite loop until it finds the value but runs the next code since I am getting <strong>'NoneType' object is not subscriptable</strong>.</p>
  
  <p>May I ask how to run as I expected? and explanation?</p>