def count_text(text):
    words = text.split()
    characters = len(text)
    lines = text.count('\n') + 1
    return len(words), characters, lines

def read_from_file(file_path):
    try:
        with open(file_path, 'r') as file:
            return file.read()
    except FileNotFoundError:
        print("File not found. Please check the file path and try again.")
        return None

def main():
    while True:
        choice = input("Enter '1' to input text or '2' to read from a file (enter 'exit' to quit): ")
        if choice == 'exit':
            break
        elif choice == '1':
            user_text = input("Enter your text: ")
            words, characters, lines = count_text(user_text)
            print(f"Words: {words}, Characters: {characters}, Lines: {lines}")
        elif choice == '2':
            file_path = input("Enter the file path: ")
            file_text = read_from_file(file_path)
            if file_text:
                words, characters, lines = count_text(file_text)
                print(f"Words: {words}, Characters: {characters}, Lines: {lines}")
        else:
            print("Invalid input. Please enter '1' or '2'.")

if __name__ == "__main__":
    main()
