path = 'res/01/input' space = [] with open(path, 'r') as file: for line in file: space.append([1 if c is '#' else 0 for c in line]) if '#' not in line: space.append([0 for _ in line]) ind = set() for i in range(len(space[0])): if '#' not in [space[i][j] for j in range(len(space))]: ind.add(i)