title: Can't differentiate the two expressions supposed to work in the same way
body: <p>Few days back I created <strong><em><a href="https://stackoverflow.com/questions/56494865/unable-to-let-my-script-keep-trying-for-few-times-when-a-condition-is-not-met">this post</a></em></strong>, to seek any solution as to how I can let my script loop in such a way so that the script will use few links to check whether my defined <code>title</code> (supposed to be extracted from each link) is nothing for <code>four</code> times. If the <code>title</code> is still nothing then the script will <code>break</code> the <code>loop</code> and go for another link to repeat the same.</p>
  
  <p>This is how I got success--► By changing <code>fetch_data(link)</code> to <code>return fetch_data(link)</code> and defining <code>counter=0</code> outside <code>while loop</code> but inside <code>if</code> statement.</p>
  
  <p>Rectified script:</p>
  
  <pre><code>import time
  import requests
  from bs4 import BeautifulSoup
  
  links = [
      "https://stackoverflow.com/questions/tagged/web-scraping?sort=newest&amp;page=2",
      "https://stackoverflow.com/questions/tagged/web-scraping?sort=newest&amp;page=3",
      "https://stackoverflow.com/questions/tagged/web-scraping?sort=newest&amp;page=4"
  ]
  counter = 0
  
  def fetch_data(link):
      global counter
      res = requests.get(link)
      soup = BeautifulSoup(res.text,"lxml")
      try:
          title = soup.select_one("p.tcode").text
      except AttributeError: title = ""
  
      if not title:
          while counter&lt;=3:
              time.sleep(1)
              print("trying {} times".format(counter))
              counter += 1
              return fetch_data(link) #First fix
          counter=0 #Second fix
  
      print("tried with this link:",link)
  
  if __name__ == '__main__':
      for link in links:
          fetch_data(link)
  </code></pre>
  
  <p>This is the output the above script produces (as desired):</p>
  
  <pre><code>trying 0 times
  trying 1 times
  trying 2 times
  trying 3 times
  tried with this link: https://stackoverflow.com/questions/tagged/web-scraping?sort=newest&amp;page=2
  trying 0 times
  trying 1 times
  trying 2 times
  trying 3 times
  tried with this link: https://stackoverflow.com/questions/tagged/web-scraping?sort=newest&amp;page=3
  trying 0 times
  trying 1 times
  trying 2 times
  trying 3 times
  tried with this link: https://stackoverflow.com/questions/tagged/web-scraping?sort=newest&amp;page=4
  </code></pre>
  
  <p><code>I used wrong selector within my script so that I can let it meet the condition I've defined above.</code></p>
  
  <blockquote>
    <p><strong><em>Why should I use <code>return fetch_data(link)</code> instead of <code>fetch_data(link)</code> as the expressions work identically most of the times?</em></strong></p>
  </blockquote>