class Solution(object):

def islandPerimeter(self, grid):

"""

:type grid: List[List[int]]

:rtype: int

"""

y_index = 0

total = 0

cover = 0

```
for y in grid:
y_index += 1
x_index = 0
for x in y:
x_index += 1
if x == 1:
total +=1
if len(grid) > y_index and grid[y_index][x_index-1] == 1:
cover += 1
if len(y) > x_index and grid[y_index-1][x_index] == 1:
cover +=1
return total*4-cover*2
```