Question #240238

Assume a text file “Test.txt” is already created. Using this file, write a function to create three

files “LOWER.TXT” which contains all the lowercase vowels and “UPPER.TXT” which contains all 

the uppercase vowels and “DIGIT.TXT” which contains all digits



Expert's answer

import re


with open("Test") as file:
    text = file.read()
    with open('DIGIT.TXT', 'w') as file:
        file.write(re.sub(r'\D+', '', text))
    with open('LOWER.TXT', 'w') as file:
        file.write(re.sub(r'[^aeiouy]+', '', text))
    with open('UPPER.TXT', 'w') as file:
        file.write(re.sub(r'[^AEIOUY]+', '', text))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS