I have a problem with the syntax "any". I have two lists.
mainseq=["hali","hulu","habi"]
seq=["a","b","c","d"]
I want to find if elements exist in seq in mainseq.
for each in seq:
if any(each in halum for halum in mainseq):
print each
This gives me a and b, as expected. But when I delete βanyβ syntax, I get all the values ββin seq, although βcβ and βdβ do not exist in mainseq.
for each in seq:
if (each in halum for halum in mainseq):
print each
What happens behind the scenes and WITHOUT "any" function? Please, help.
source
share