Task:
Given an array arr of strings complete the function landPerimeter by calculating the total perimeter of all the islands. Each piece of land will be marked with 'X' while the water fields are represented as 'O'. Consider each tile being a perfect 1 x 1piece of land. Some examples for better visualization:
['XOOXO',
  'XOOXO',
  'OOOXO',
  'XXOXO',
  'OXOOO'] 
or 
should return:
"Total land perimeter: 24",
while
['XOOO',
  'XOXO',
  'XOXO',
  'OOXX',
  'OOOO']
should return: "Total land perimeter: 18"
Good luck!
def land_perimeter(arr):
    a, b = ' '.join(arr), ' '.join(''.join(x) for x in zip(*arr))
    p = 4 * a.count('X') - 2 * 'O{}O{}O'.format(a, b).split('X').count('')
    return 'Total land perimeter: {}'.format(p)
def land_perimeter(arr):
    a, b = ' '.join(arr), ' '.join(''.join(x) for x in zip(*arr))
    p = 4 * a.count('X') - 2 * 'O{}O{}O'.format(a, b).split('X').count('')
    return 'Total land perimeter: {}'.format(p)