Set
noun
say it: “SET” /sɛt/
A Python collection that holds each value only once and keeps no particular order, written in curly braces, such as {"ana", "ben"}.
What is a set in Python?
A set is a collection with no duplicates and no particular order. It's the quickest way to remove repeats.
visitors = ["ana", "ben", "ana", "cai"]
unique = set(visitors)
print(len(unique)) # 3
In a sentence
- “Turning the visitor list into a set removed the repeated names.”
- “The set of tags kept "vegan" only once, however many times it was added.”
Level: Apprentice · More Python terms at this level
Updated