title: index out of range with BeautifulSoup
body: <p>I tried to understand this nasty index out of range error for some time but I can not figure out why it shows up.</p>
  
  <p>The output is what I am expecting with a correct number of results.
  I cannot catch the empty one that I guess it raising the error.</p>
  
  <p>In the code below I tried to capture the error but I must to something wrong.
  I tried as well the len() method.
  I'm counting the number of iteration as well.</p>
  
  <pre><code>#Import lib needed
  from urllib.request import urlopen as uReq
  from bs4 import BeautifulSoup as soup
  
  #-----------------------------------------Importing data -----------------------------------------------------------------#
  #Page with number of adds per location
  
  my_url_nb_Nimes_building = 'https://www.leboncoin.fr/ventes_immobilieres/offres/?th=1&amp;q=immeuble&amp;it=1&amp;location=N%EEmes&amp;ret=1&amp;ret=2&amp;ret=5'
  #Opening connection, grabbing the page, close connection
  uClientnimesbuild = uReq(my_url_nb_Nimes_building)
  page_htmlnimesbuild =  uClientnimesbuild.read()
  uClientnimesbuild.close()
  
  page_soupnimesbuild = soup(page_htmlnimesbuild, "html.parser")
  
  
  containglobalnbnimesbuild = ((page_soupnimesbuild).find_all("section",{"class":"item_infos"}))
  
  
  count = 0
  for contain in containglobalnbnimesbuild:
      try:
          titlecontain = contain.find_all("h2",{"class":"item_title"})
          title = titlecontain[0]
          print("Titre:", title)
          count = count +1
          print(count)
      except ValueError:
          print("inerror")
  </code></pre>
  
  <p>Would you have any idea what I am doing wrong to catch this.</p>
  
  <pre><code>    title = titlecontain[0]
  IndexError: list index out of range
  </code></pre>
  
  <p>Thanks a lot </p>