Verify part of file name exists in a dictionary or list, Python 2.7
<p>I'm new to coding and working on the early stages of a file checking program.
I'm writing a program to see whether a file contains "correct information" in its title or not.</p>

<p>I'm currently stuck on how to check to see if <code>part</code> of a title matches an acceptable name in a dictionary or list.</p>

<p>My code is below. If I put in a title that contains less than 3 parts, an error is thrown. However, if I put in a title with 3 <code>parts</code>, even if none of the <code>parts</code> match anything in the lists or dictionary, my program claims the title is correct (which it's not).</p>

<p>I know the <code>if-statements</code> are rough because of all the or's, but it's the best idea I have right now in lieu of writing a ton of <code>if-statements</code> for each <code>part</code>.</p>

<p>Can anybody help me with correcting the code so that I can check part of a title against a list or dictionary to ensure that part exists in the list/dictionary? </p>

<p>An example (correct) file name would be: <code>DJ_BR_UVT.xls</code>
and an example of an incorrect file name is:<code>DJ_BR_staford.xls</code>
*as a side note, the <code>parts</code> or species, school, initials, can be in any order in the file name.</p>

<pre><code>def checkFilename(filename):
    print 'filename = ' + filename
    Parts = filename.split('_')
if len(Parts) != 3:
    print "There are " + str(len(Parts)) + " that is an incorrect amount of info in file name. There should be 3 parts to your file name"
    return

Part1 = Parts[0]
Part2 = Parts[1]
Part3 = Parts[2]
Species_Dictionary = {'Brown Rat':'BR', 'Black Rat':'BLR', 'Dwarf Rat':'DR', 'White Mouse':'GG', 'Human':'HS', 'Brown Mouse':'VK'}
School_List = ['UHJ', 'UMG', 'COL', 'UVT']
Initials_List = ['DM', 'DCM', 'YXAA', 'DJ']
Species_Check = 0
School_Check = 0
Initials_Check = 0
# supposed to check to see if each 'part' can be found in the Species_Dictionary
if Part1 or Part2 or Part3 in Species_Dictionary:
    Species_Check = 1
    print Species_Check
else:
    print "Cannot find a valid species"
    return

#check to see if any of the 'parts' can be found in the School-List
if Part1 or Part2 or Part3 in School_List:
    School_Check = 1
else:
    print "Cannot find valid school"
    return

#Check if any of the 'parts' are in the Initials_List
if Part1 or Part2 or Part3 in Initials_List:
    Initials_Check = 1
else:
    print "Cannot find valid initials"
    return

#If the previous 3 if-statements have been met, the file 'passes' and contains correct info
if Species_Check == 1 and School_Check == 1 and Initials_Check == 1:
    print "Your file contains correct title information"
else:
    print "Your file name does not contain the correct information"
    return
</code></pre>