I want the Python to select a multi viable in the if at the same time | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 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

17th Oct 2022, 10:28 AM
CODEnight8
CODEnight8 - avatar
4 Respuestas
+ 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.
17th Oct 2022, 11:54 AM
Lothar
Lothar - avatar
+ 1
Instead a[0],b[1],c[2] Put a,b,c
17th Oct 2022, 11:34 AM
Riya
Riya - avatar
0
I did this to choose a specific massage that will respond with a special message
17th Oct 2022, 11:44 AM
CODEnight8
CODEnight8 - avatar
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)
17th Oct 2022, 2:40 PM
Bob_Li
Bob_Li - avatar