I am trying the **scrape** the table from the wikipedia page
<https://en.wikipedia.org/wiki/List_of_postal_codes_of_Canada:_M>

I got the html, found the part containing the table I want:

```
<table class="wikitable sortable">
 <tbody>
  <tr>
   <th>Postcode</th>
   <th>Borough</th>
   <th>Neighbourhood</th>
  </tr>
 <tr>
  <td>M1A</td>
  <td>Not assigned</td>
  <td>Not assigned</td>
 </tr>
 <tr>
  <td>M2A</td>
  <td>Not assigned</td>
  <td>Not assigned</td>
 </tr>
  <tr>
   <td>M3A</td>
   <td><a href="/wiki/North_York" title="North York">North York</a></td>
   <td><a href="/wiki/Parkwoods" title="Parkwoods">Parkwoods</a></td>
  </tr>
 <tr>
  <td>M4A</td>
  <td><a href="/wiki/North_York" title="North York">North York</a></td>
  <td><a href="/wiki/Victoria_Village" title="Victoria Village">Victoria Village</a></td>
 </tr>
 <tr>
  <td>M5A</td>
  <td><a href="/wiki/Downtown_Toronto" title="Downtown Toronto">Downtown Toronto</a></td>
  <td><a href="/wiki/Harbourfront_(Toronto)" title="Harbourfront (Toronto)">Harbourfront</a></td>
  </tr>
 <tr>
.
.
.

```

I then tried the following:

```
PostalCode=[]
for row in My_table.findAll('tr')[1:]:
    PostalCode_cell=row.findAll('td')[0]
    PostalCode.append(PostalCode_cell.text)

print(PostalCode) 

```

The output is what I have expected:

```
['M1A', 'M2A', 'M3A', 'M4A', 'M5A', 'M5A', 'M6A', 'M6A', 'M7A', 'M8A', 'M9A', 'M1B', 'M1B', 'M2B', 'M3B', 'M4B', 'M4B', 'M5B', 'M5B', 'M6B', ...

```

However, when I want to do the same thing for Borough and Neighbourhood,I always get 'list index out of range'
Here are the codes I used for Borough and Neighbourhood:

```
Borough=[]
for row in My_table.findAll('td') :
    Borough_cell=row.findAll('a')[0]
    Borough.append(Borough_cell.text)
print(Borough)

```

```
Neighbourhood=[]
for row in My_table.findAll('td'):
    Neighbourhood_cell=row.findAll('a')[1]
    Neighbourhood.append(Neighbourhood_cell.text)
print(Neighbourhood)

```

I do notice that in Borough and Neighbourhood there are value "Not Assigned"(which has no 'a'), I do not know if it is these values that cause the problem.
My expected result is to get the table in to pandas format for further processing.