so I am trying to code for an RLE program. I need to compress and decompress files, but I struggled to check if a file exists or not. can you help me with this please!
this is my programming so far:
file2 = input('Enter name of file containing the RLE compressed data: ')
# takes the name of the file
    if file2.exist():
        text = open(file2, 'r')  # opens the file and reads it only    
        decode = ''
        count = ''
        data = input('Enter the name of the file to be compressed: ')
        for char in data:
            if char.isdigit():  # numerical char apears 
                 # isdigit() checks if it contain digits; if yes or no
                 count += char  # its added to the count
            else:  # new char appears
                 decode += char * int(count) 
                 # ^ decompress the char according to the count num
                 count = ''  # saves the new count num
     else:
        print('File name not found.')
I know that I need to fix the part where it says data = input('Enter the name of the file to be compressed: ') but I will do it later after fixing the file part. I kind of have an idea of how to do it.
 
     
    