0
What can I do if I want to check that the input is containing the elements from the list ?(py)
List = (tyh,yaa,) Input:tyhuha Output:true
3 Réponses
+ 1
thats a tuple, and check this out:
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2432/
+ 1
Thx
sarada lakshmi
0
Use "in" operator to check whether the i/p contains elements from the list.
Like,
l=["tyh", "yaa"]
n=input()
for i in l:
if i in n:
print("True")
break
else:
print("False")
break
And hope there might be many short codes than this..
But, remember lists are represented using [ ] if it's tuple, what you used there was crt. If it's list plz change..