Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

How to Get the Difference Between Sets in Python

firstSet = {2, 3, 4, 5}

secondSet = {1, 3, 5, 7}

print(firstSet - secondSet)
# {2, 4}
Comment

difference() Function of sets in python

# The difference() function can be used to create a new set containing the difference
# from one set with another

mySet = {1, 2, 3, 4}
mySet2 = {3, 4, 5, 6}
mySet3 = mySet.difference(mySet2)
print(mySet3)

# Output:
# {1, 2}
Comment

PREVIOUS NEXT
Code Example
Python :: Comparing Sets with issubset() Function in python 
Python :: how to check if a function is callable in puyjom 
Python :: python equivalent linkedhashmap 
Python :: for loop for multiple things 
Python :: How to sort a list by even or odd numbers using a filter? 
Python :: numpy retrieve 5 highest value index 
Python :: tables in django 
Python :: change value of element 
Python :: how to fix value error in model.fit 
Python :: Instance Method With Property In Python 
Python :: run c code in python 
Python :: operator overloading in python 
Python :: Get First From Table Django 
Python :: get database image in dajngo 
Python :: 0 in python 
Python :: Implementing Java-style getters and setters in Python 
Python :: how to detect if a key was press down 
Python :: python long multiline text 
Python :: quicksort python3 
Python :: networkx - unique combinations of paths 
Python :: print chr character in python f string 
Python :: split column in exact spot python 
Python :: cos2x 
Python :: python inline print variable 
Python :: django.com 
Python :: python site-packages pyspark 
Python :: Reading from a file way01 
Python :: Python Creating a Tuple 
Python :: numpy addition operation using numpy functions 
Python :: In addition to indexing, slicing is also supported. While indexing is used to obtain individual characters, slicing allows you to obtain substring: 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =