with open('11.txt') as f:
    nums = [(['X'] + [int(num) for num in line.split(' ')] + ['X']) for
        line in f.read().split('\n')]
nums = ['X'] * (len(nums[0]) + 2) + nums + ['X'] * (len(nums[0]) + 2)
How to DRY up directional logic from a try/except mess