x = [\'A\',\'AA\',\'AABA\',\'AAL\',\'AAP\',\'AAPL\',\'ABBV\',\'ABC\',\'ABMD\',\'ABT\'] list12 = file.loc[file[\'Firm Name\'].isin(x)] #file3 def findindex(list12,A,B