+ 1
I want the Python to select a multi viable in the if at the same time
if I have a=("where", "when", "what") b=("is", "are", "am") c=("it", "he", "you") d=input("").lower() and I want(if the user input where are you in d print("everywhere ") I tried (if d in (a[0] and b[1] and c[2]): print("everywhere ") ) but it didn't work
4 Answers
+ 7
Mohammed Fuad ,
not quite clear what you are going to achieve.
you have mentioned that if user gives input "everywhere", you wanted to check if you can find "everywhere" in `a`, `b`, `c`. you can not find it there, because it is nof written there.
do you wanted to check if an element (ore more elements) from `a`, `b`, `c` can be found in the input string ?
it could be helpful for us if you if you elaborate your question and give an input and and output sample. it also would be great if you can post the original task description here.
+ 1
Instead a[0],b[1],c[2]
Put a,b,c
0
I did this to choose a specific massage that will respond with a special message
0
why not just use a dictionary?
qa = {
"where are you":"everywhere",
"when is it":"now",
"what is he":"confused"
}
d = input().lower()
for k, v in qa.items():
if d==k:
print(v)