Sobes.tech
Intern — Senior

Determining the presence of an element in different types of Python collections

livecode

Task condition

What will be the output of the program below?

x = [i for i in range(10)]
y = {i for i in range(10)}
z = (i for i in range(10))

print(3 in x)
print(3 in y)
print(3 in z)

The question tests how the in operator works with a list, a set, and a generator.