I have the following script in Python that is meant to find words with two or more vowels in them and output the result to a txt file. The script currently runs, but the output file is empty. I have tried several different methods to no avail, any idea why the output file is blank? I am using the (re) import to treat the input as a regular expression.
#!C:\Python33\python.exe
import re
file = open("Text of Steve Jobs' Commencement address (2005).htm");
output = open('twoVoweledWordList.txt', 'w');
for word in file.read():
if len(re.findall('[aeiouy]', word)) >= 2:
match == True;
while True :
output.write(word, '\n');
file.close()
output.close()
match == Trueis a comparison, not an assignment. Also, in Python you don't need a semicolon on the end of any line.matchflag or anything else like that.if len(re.findall('[aeiouy]', word)) >= 2is already exactly the condition under which we want to write thewordto the output file, and we want to write that givenwordexactly once.