Jul-22-2021, 11:58 PM
I'm just an amateur, but I thought this might help on a different track:
import random # just for making the strings # list of things we want, add what you like or generate it wanted = ['AH', 'MH', 'GL', 'ML'] # list of things we need to check, add what you like or generate it check_list = ['GL'] # list of things we do not want in combination with check_list, add what you like or generate it not_wanted_in_comboGL = ['ML'] # if for example you also don't want AH in combo with say MH # not_wanted_in_comboAH = ['MH'] # you need another if in lookup(alist) # make a random test set as a substitute for mStrip def makeTestset(): test_set = [] while len(test_set) < 10: randomUpperLetter1 = chr(random.randint(ord('A'), ord('M'))) randomUpperLetter2 = chr(random.randint(ord('A'), ord('M'))) string = randomUpperLetter1 + randomUpperLetter2 if string in wanted: test_set.append(string) print(string) return test_set def lookup(mylist): # maybe there are no unwanted combinations for x in mylist: if x in wanted: result = 'OK' print(x, result) if x in check_list: # check if an unwanted combination is there for y in mylist: if y in not_wanted_in_comboGL: result = 'not OK' print(x, y, result) # break if an unwanted combination is found return result return result alist = makeTestset() answer = lookup(alist) print(answer)