with open('../input.text', 'r') as file: data: str = file.read() floor = 0 for i, char in enumerate(data): if char == '(': floor += 1 elif char == ')': floor -= 1 if floor == -1: print(f'The position of the character that causes Santa to first enter the basement is {i + 1}') exit(0)