This is the code given below.
k = [1, 8, 15]
g = (x for x in k if k.count(x) > 0)
k = [2, 8, 22]
print(list(g))
I am getting the output as [8] but it should be [1,8,15], right? since each element is present at least once.
Any plausible explanation for the answer?