a = [12, 34, 542, 12, 63653, 635, 635] def foo(i): print(i) return i seen = set() print(not any(i in seen or seen.add(i) for i in a))