Write a function, island_count, that takes in a grid containing Ws and Ls. W represents water and L represents land. The function should return the number of islands on the grid. An island is a vertically or horizontally connected region of land.
grid = [
['W', 'L', 'W', 'W', 'W'],
['W', 'L', 'W', 'W', 'W'],
['W', 'W', 'W', 'L', 'W'],
['W', 'W', 'L', 'L', 'W'],
['L', 'W', 'W', 'L', 'L'],
['L', 'L', 'W', 'W', 'W'],
]
island_count(grid) # -> 3grid = [
['L', 'W', 'W', 'L', 'W'],
['L', 'W', 'W', 'L', 'L'],
['W', 'L', 'W', 'L', 'W'],
['W', 'W', 'W', 'W', 'W'],
['W', 'W', 'L', 'L', 'L'],
]
island_count(grid) # -> 4grid = [
['L', 'L', 'L'],
['L', 'L', 'L'],
['L', 'L', 'L'],
]
island_count(grid) # -> 1grid = [
['W', 'W'],
['W', 'W'],
['W', 'W'],
]
island_count(grid) # -> 0