Oct-02-2019, 09:14 AM
Hello,
I'm trying to make a function that returns true if a list contains at least one of many predetermined letters in it. The code is as follows:
Am I using 'and' wrong?
I'm trying to make a function that returns true if a list contains at least one of many predetermined letters in it. The code is as follows:
def check(x): if 'A' and 'B' and 'C' in x: return True elif 'A' and 'D' and 'G' in x: return True elif 'A' and 'E' and 'I' in x: return True elif 'I' and 'H' and 'G' in x: return True elif 'I' and 'F' and 'C' in x: return True elif 'D' and 'E' and 'F' in x: return True elif 'B' and 'E' and 'H' in x: return True else: return False L = ['A', 'B', 'E', 'F'] print(check(L))In this instance it should return false, since there are none of the series of three letters that I'm checking for, but it somehow returns true...
Am I using 'and' wrong?