title: Why String comparison "==" doesn't work? Python 3.6
body: <p>I am trying to write a function that takes a part number and then retrieves its product webpage link from this website: <a href="http://www.assmann-wsw.com" rel="nofollow noreferrer">http://www.assmann-wsw.com</a></p>
  
  <p>I am using the bs4 module to parse the webpage. 
  The url follows this structure when doing a part number search:</p>
  
  <p>"<a href="http://www.assmann-wsw.com/us/en/artikelfinder/?artnr=" rel="nofollow noreferrer">http://www.assmann-wsw.com/us/en/artikelfinder/?artnr=</a>" + part_number + "&amp;artnr-search=find+now#searchresults"</p>
  
  <p>This line collects all part numbers in 'td' tag. </p>
  
  <pre><code>all_artnr = soup.find_all('td', attrs={'class': 'artnr'})
  </code></pre>
  
  <p>There are three scenarios when searching a part number:</p>
  
  <p>(1). Part number doesn't exist</p>
  
  <p>(2). Part number exists and it is not a substring of other part numbers.</p>
  
  <p>(3). Part number exists and it is a substring of other part numbers. </p>
  
  <p>Scenarios (1) and (2) are handled easily. In scenario 3, the website returns all product webpage of part numbers that contains the input part number as a substring. </p>
  
  <p>I was thinking to compare the text of the td tag with the input part number. When they match, the product webpage is contained in that td tag. </p>
  
  <p>Below is the code I have and its output. 
  The last two outputs show a match, but the comparison returns false. 
  Please help me understand what is happening here. Thank you.</p>
  
  <pre><code>import bs4
  import requests
  
  
  def get_pwp(pn):
      home_page = "http://www.assmann-wsw.com/"
      #url_p1_de = "http://www.assmann-wsw.com/wo/en/artikelfinder/?artnr="
      url_p1_us = "http://www.assmann-wsw.com/us/en/artikelfinder/?artnr="
      url_p2 = "&amp;artnr-search=find+now#searchresults"
  
      search_url = url_p1_us + str(pn) + url_p2
      src = requests.get(search_url).content
  
      soup = bs4.BeautifulSoup(src, 'lxml')
  
      # product webpage
      pwp = ''
      all_artnr = soup.find_all('td', attrs={'class': 'artnr'})
  
      # Part number doesn't exist
      if len(all_artnr) == 0:
          pwp = '#NA'
  
      # Part number exists and it is not a substring of other part numbers.
      elif len(all_artnr) == 2 or len(all_artnr) == 1:
          pwp = home_page + all_artnr[0].find('a')['href']
  
      # Part number exists and it is a substring of other part numbers.
      else:
          for artnr in all_artnr:
              print(str(artnr.text), pn)
              print(str(artnr.text) == pn)
  
              if str(artnr.text) == str(pn):
                  pwp = home_page + artnrfind('a')['href']
                  break
  
      return pwp
  
  pwp = get_pwp("A-MCSP-80300")
  print(pwp)
  
  
  
  Output:
  
  A‑MCSP‑80300‑R A-MCSP-80300
  False
  A‑MCSP‑80300‑R A-MCSP-80300
  False
  A‑MCSP‑80300/B A-MCSP-80300
  False
  A‑MCSP‑80300/B A-MCSP-80300
  False
  A‑MCSP‑80300/G A-MCSP-80300
  False
  A‑MCSP‑80300/G A-MCSP-80300
  False
  A‑MCSP‑80300/R A-MCSP-80300
  False
  A‑MCSP‑80300/R A-MCSP-80300
  False
  A‑MCSP‑80300/Y A-MCSP-80300
  False
  A‑MCSP‑80300/Y A-MCSP-80300
  False
  A‑MCSP‑80300 A-MCSP-80300
  False
  A‑MCSP‑80300 A-MCSP-80300
  False
  
  
  Process finished with exit code 0
  </code></pre>