title: How to prevent Python function from returning None
body: <p>I am parsing HTML table with BeautifulSoup like this:</p>
  <pre><code>for tr in table_body.find_all('tr'):      
              for td in tr:  
                  if td.text == 'Description':
                      description = td.find_next('td').text
                  if td.text == 'Category':
                      category = td.find_next('td').text                             
                  if td.text == 'Department':
                      department = td.find_next('td').text                             
                  if td.text == 'Justification':
                      justification = td.find_next('td').text
  print(description, category, department, justification)
  </code></pre>
  <p>I refactored the multiple <code>if</code> statements into a function:</p>
  <pre><code>def html_check(td, text):
          if td.text == text:
              value = td.find_next('td').text
              return value
  </code></pre>
  <p>that is called like this:</p>
  <pre><code>for tr in table_body.find_all('tr'):      
              for td in tr:  
                  description= html_check(td, 'Description')
                  category = html_check(td, 'Category')
                  department = html_check(td, 'Department')
                  justification = html_check(td, 'Justification')
  print(description, category, department, justification)
  </code></pre>
  <p>My problem is that when the function <code>html_check</code> will not find a match, it will return <code>None</code>, which will be printed. This is not desirable.</p>
  <p>Is there any way to make this function return a value only when the if condition in it is met?</p>