Sobes.tech
Junior — Senior

Determining the final content of a set after conditional addition

livecode

Task condition

Analyze which elements will be present in the set after the loop completes, and predict what will be displayed in the output.

a = set()
for i in range(1000):
    a.add(1)
    if i % 2 == 0:
        a.add(2)

print(a)
Determining the final content of a set after… - sobes.tech