Fill: Set Add
Fill in the Blank Easy
Question
Fill in the blank to add 4 to the set.
Code
s = {1, 2, 3}
s.___(4)
Hint
Sets use a different method name than lists for adding.
Explanation
add() adds a single element to a set. If the element already exists, the set is unchanged (sets only contain unique elements). After s.add(4), s is {1, 2, 3, 4}.
Related Resources
Related Lessons
- Sets
Set methods.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.