I have a script which searches file(X) for a keyword however, I want to search file(X) with file(y) which contains multiple keywords.
Source:
lines1 = [line1.rstrip('\n') for line1 in open('file(X)')]
print'------'
print lines1
print'------'
Colors = lines1
ColorSelect = 'Brown'
while str.upper(ColorSelect) != "QUIT":
if (Colors.count(ColorSelect) >= 1):
print'The color ' + ColorSelect + ' exists in the list!'
break
elif (str.upper(ColorSelect) != "QUIT"):
print'The list does not contain the color ' + ColorSelect
break
Output:
C:\Users\Foo\Bar\Python\Test\>C:\python27\python Test.py
------
['Red', 'Orange', 'Yellow', 'Green', 'Blue', 'Brown']
------
The color Brown exists in the list!
Press any key to continue . . .
What I want:
C:\Users\Foo\Bar\Python\Test\>C:\python27\python Test.py
------
['Red', 'Orange', 'Yellow', 'Green', 'Blue', 'Brown']
------
The color Brown exists in the list!
The color Yellow exists in the list!
The color Red exists in the list!
Press any key to continue . . .
I would like ColorSelect = 'Brown' to be something like ColorSelect = file_containing_words_to_search_for.txt aka[file(Y)]