-1

I have a variable called 'command' and I want to check whether command contains any of a certain list. For instance, if I have a list with ["a", "b", "c"] and I want to detect if command has any of those elements in it. So if command is "abc" it will return true for that if statement and if command is "ABC" it will return false.

  • 1
    Be careful that you don't run into the [Scunthorp problem](https://en.wikipedia.org/wiki/Scunthorpe_problem). – Mark Ransom Dec 26 '21 at 17:03

2 Answers2

3
def command_contains_element(command, element_list):
    return any(c in command for c in element_list)
tmarice
  • 458
  • 4
  • 8
-1

This might do the work:

isTrue = False
for i in ["a","b","c"]: #List you said
    if i in command: #command "abc"
        isTrue = True
        break
print(isTrue)

Soyokaze
  • 157
  • 8