Substring query | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Substring query

words = ["spam", "egg", "spam", "sausage"] mwords= ["spam", "eggs"] print(mwords in words) Why above code returns 'False'?

24th Aug 2020, 12:30 PM
Divya
1 Answer
+ 5
It gives false because you've queried for an array i.e ["spam", "eggs"] which is not in words. You could query for either spam or eggs separately then you'd get true.
24th Aug 2020, 12:47 PM
Takudzwa Nelson Chiutaalenga
Takudzwa Nelson Chiutaalenga - avatar