from typing import Tuple def read_file_safe(path: str) -> Tuple[int, int]: try: with open(path) as file: words = 0 lines = 0 for line in file.readlines(): lines += 1 words += len([word for word in line.split()]) return (lines, words) except: return (0, 0) lines, words = read_file_safe("text.txt") print(f"Строк: {lines}, слов: {words}")