#!/usr/bin/python3
"""
IslandPerimiter module
"""


def island_perimeter(grid):
    """
        Returns the perimeter of given island
    """
    w = len(grid[0])
    h = len(grid)
    perimeter = 0

    for i, col in enumerate(grid):
        for j, row in enumerate(col):
            if row == 1:
                perimeter += 4
                if grid[i][j-1] == 1:
                    perimeter -= 1
                if grid[i][(j+1) % w] == 1:
                    perimeter -= 1
                if grid[(i+1) % h][j] == 1:
                    perimeter -= 1
                if grid[i-1][j] == 1:
                    perimeter -= 1
    return perimeter

08e8b8f088a4c3b9d93d1e51ed4c5f4f03e6d7ce
<mask token>

<mask token>


def island_perimeter(grid):
    """
        Returns the perimeter of given island
    """
    w = len(grid[0])
    h = len(grid)
    perimeter = 0
    for i, col in enumerate(grid):
        for j, row in enumerate(col):
            if row == 1:
                perimeter += 4
                if grid[i][j - 1] == 1:
                    perimeter -= 1
                if grid[i][(j + 1) % w] == 1:
                    perimeter -= 1
                if grid[(i + 1) % h][j] == 1:
                    perimeter -= 1
                if grid[i - 1][j] == 1:
                    perimeter -= 1
    return perimeter

#!/usr/bin/python3
"""
IslandPerimiter module
"""


def island_perimeter(grid):
    """
        Returns the perimeter of given island
    """
    w = len(grid[0])
    h = len(grid)
    perimeter = 0

    for i, col in enumerate(grid):
        for j, row in enumerate(col):
            if row == 1:
                perimeter += 4
                if grid[i][j-1] == 1:
                    perimeter -= 1
                if grid[i][(j+1) % w] == 1:
                    perimeter -= 1
                if grid[(i+1) % h][j] == 1:
                    perimeter -= 1
                if grid[i-1][j] == 1:
                    perimeter -= 1
    return perimeter
