What can I do if I want to check that the input is containing the elements from the list ?(py) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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

15th Aug 2020, 7:21 AM
S.G.INGALE
S.G.INGALE - avatar
3 Answers
15th Aug 2020, 7:33 AM
Slick
Slick - avatar
15th Aug 2020, 7:36 AM
S.G.INGALE
S.G.INGALE - avatar
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..
15th Aug 2020, 7:35 AM
sarada lakshmi
sarada lakshmi - avatar