Question: I tried to understand this nasty index out of range error for some time but I can not figure out why it shows up.

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.

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.

```
#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&q=immeuble&it=1&location=N%EEmes&ret=1&ret=2&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")

```

Would you have any idea what I am doing wrong to catch this.

```
    title = titlecontain[0]
IndexError: list index out of range

```

Thanks a lot

Answer: 
First, in the order you define the classes, class `second` is not known at the time it is used in `first`. You should actually get other error messages.
Second, in the initializer list, you need to address the variable to initialize by its name (i.e. `: secondAvl(-1)`), not by its type `: second(-1)`.

See the following working example:

```
class second {

private:

public:
    second(int key) {} // here it worked to call contructor for tree
};

class first{

private:

    second secondAvl;
public:

    first():secondAvl(-1){}  // i get erroe here
};

```
do instead:

```
...

private:

    second secondAvl;
public:

    first() : secondAvl(-1)
    { }  
}

```

or uniform initialization using {}

```
...

private:

    second secondAvl;
public:

    first() : secondAvl{-1}
    { }  
}

```