Here’s a Python program that reads characters from the keyboard one by one and stores them in separate files based on their case:

lower_file = 'LOWER.txt'
upper_file = 'UPPER.txt'
others_file = 'OTHERS.txt'

    with open(lower_file, 'w') as lower:
        with open(upper_file, 'w') as upper:
            with open(others_file, 'w') as others:
                while True:
                    char = input("Enter a character (or 'q' to quit): ")
                    if char == 'q':
                    elif char.islower():
                    elif char.isupper():

    print("Characters saved to respective files.")

except IOError:
    print("An error occurred while writing to the files.")


When you run the program, it will prompt you to enter a character. You can enter characters one by one. If you enter a lowercase letter, it will be stored in the file 'LOWER.txt'. If you enter an uppercase letter, it will be stored in the file 'UPPER.txt'. If you enter any other character, it will be stored in the file 'OTHERS.txt'. You can stop entering characters by typing 'q'. The program will create and write to the files 'LOWER.txt', 'UPPER.txt', and 'OTHERS.txt' in the same directory as the script.

Please ensure that you have write permissions in the directory where the script is located.

By admin

Leave a Reply

Your email address will not be published. Required fields are marked *