#week 8 - challenge solution

def vowelCalc(fileName):
    file = open(fileName, "r")
    text = file.read().lower()
    a = text.count("a")
    e = text.count("e")
    i = text.count("i")
    o = text.count("o")
    u = text.count("u")
    vowels = a+e+i+o+u
    return vowels

def storeVowels(fileName,vowels):
    file = open("vowels.txt", "a")
    file.write(fileName+" contains "+str(vowels)+" vowels\n")
    file.close()

repeat=True
while repeat==True:
    fileName=input("Enter the name of the text file: ")
    vowels = vowelCalc(fileName)
    print(fileName,"contains",vowels,"vowels")
    storeVowels(fileName,vowels)






