About 11,300,000 results
Open links in new tab
  1. python - Best way to find the intersection of multiple sets? - Stack ...

    From Python version 2.6 on you can use multiple arguments to set.intersection(), like

  2. Are Python sets mutable? - Stack Overflow

    Jan 7, 2013 · 14 Python sets are classified into two types. Mutable and immutable. A set created with 'set' is mutable while the one created with 'frozenset' is immutable.

  3. Append values to a set in Python - Stack Overflow

    Aug 2, 2010 · a.update([3, 4]) >>> print(a) {1, 2, 3, 4} Note: Since set elements must be hashable, and lists are considered mutable, you cannot add a list to a set. You also cannot add other …

  4. python - How do I add two sets? - Stack Overflow

    Apr 15, 2015 · c = a | b Sets are unordered sequences of unique values. a | b, or a.union(b), is the union of the two sets — i.e., a new set with all values found in either set. This is a class of …

  5. python - Sorting a set of values - Stack Overflow

    Since Python 3.7, dicts keep insertion order. So if you want to order a set but still want to be able to do membership checks in constant time, you can create a dictionary from the sorted list …

  6. In Python, when to use a Dictionary, List or Set?

    Jul 1, 2019 · 1 Dictionary: A python dictionary is used like a hash table with key as index and object as value. List: A list is used for holding objects in an array indexed by position of that …

  7. How can I create a Set of Sets in Python? - Stack Overflow

    152 Python's complaining because the inner set objects are mutable and thus not hashable. The solution is to use frozenset for the inner sets, to indicate that you have no intention of …

  8. Union of multiple sets in python - Stack Overflow

    Jun 11, 2015 · Union of multiple sets in python Asked 10 years, 6 months ago Modified 3 years, 6 months ago Viewed 85k times

  9. Efficiently compare two sets in Python - Stack Overflow

    Efficiently compare two sets in Python Asked 8 years, 2 months ago Modified 1 year, 9 months ago Viewed 86k times

  10. python - How to join two sets in one line without using "|" - Stack ...

    Jul 2, 2013 · Assume that S and T are assigned sets. Without using the join operator |, how can I find the union of the two sets? This, for example, finds the intersection: S = {1 ...