A set of viewers that drops duplicates
Predict the output · Basic · §4.4 Sets
This code collects the people who viewed a post in a set. Predict the output without running the code.
Code
viewers = {"mina", "jun", "mina", "sora"}
print(len(viewers))
viewers.add("jun")
viewers.add("dami")
viewers.remove("mina")
print(len(viewers))
print("mina" in viewers, "dami" in viewers)Solve this problem in your browser
Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.