import os

def get_text():
    choice = input("Do you want to input the text directly (1) or read from a file (2)? ")
    if choice == '1':
        text = input("Please enter the text: ")
    elif choice == '2':
        filename = input("Please enter the filename: ")
        with open(filename, 'r') as file:
            text = file.read()
    else:
        print("Invalid choice. Please try again.")
        return get_text()
    return text

def count_text(text):
    words = len(text.split())
    characters = len(text)
    lines = text.count('\n') + 1
    return words, characters, lines

def main():
    while True:
        text = get_text()
        words, characters, lines = count_text(text)
        print(f"Number of words: {words}")
        print(f"Number of characters: {characters}")
        print(f"Number of lines: {lines}")
        again = input("Do you want to perform another operation (y/n)? ")
        if again.lower() != 'y':
            print("thank u ")
            break

if __name__ == "__main__":
    main()
