I'm new to python. I need to find the words in a list that contains these vowels using regular expressions. The following does not work. Can anyone see what needs to be corrected? Thank you.
import re
file = open('wordlist.txt', 'r')
print re.findall('[aie]', file)
I get this error:
Traceback (most recent call last):
File "C:\Python27\MyScripts\script2.py", line 3, in ` <module>
print re.findall('[aie]', file)
File "C:\Python27\lib\re.py", line 181, in findall
return _compile(pattern, flags).findall(string)
TypeError: expected string or buffer
Here is what is in the wordlist, which I can retrieve by using this:
file = open('wordlist.txt', 'r')
print file.read()`
Prints out:
ae
The
Intelligent
Assistance
Revolution
may
not
be
televised
but
it
will
definitely
be