Say, for example, I have some code that goes like this:
sentence = input("Enter input: ")
target_letter = "a" or "b" or "c"
print(sentence.index(target_letter))
My main aim is to get the program to print any of the target letters' minimum index in the sentence. However when the Boolean "or" operators are used here it only recognizes the first string in the variable. For example: If I type
Ice cream
The program should recognize the 'c' as the first valid string in the index and print "1" but it skips to 'a' and prints "7".
The same sort of problem arises with the "and" operator:
sentence = input("Enter input: ")
target_letter = "a" and "b" and "c"
print(sentence.index(target_letter))
This time the program only recognizes the last string in the variable instead, if I type:
Exactly
The program throws back "3" becuase c's index is 3 but the first letter is actually 'a' with index 2. And when the input had only a "b" in it out of the strings, the program threw an error because it was neither the first string or the last string.
How would this problem be fixed so that I could place multiple possible strings in a variable so that one of the strings in the variable would be recognized later in the program?