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 isdisjoint() Function in python 
Python :: How to clear out a set in python 
Python :: python linkedhashmap 
Python :: Move Mouse Every Minute Using Python 3 & PyAutoGUI 
Python :: python Detect Cycle in a Directed Graph 
Python :: keep 0 in front of number pandas read csv 
Python :: Create Admin Interface For Objects 
Python :: Create An Empty List(Array) In Python 
Python :: yml file for django 
Python :: gensim word2vec loop keyed vector 
Python :: python static typing 
Python :: python convert string object to int object 
Python :: Get First In Table Django 
Python :: enter three numbers and find smallest number in python 
Python :: round to 0 decimal 
Python :: await not working python 
Python :: twitter python 
Python :: python find occurance of item 
Python :: geodataframe and geoseries 
Python :: reveal a defined function in python 
Python :: signup generic 
Python :: integrate label into listbox tkinter 
Python :: The module in NAME could not be imported: django.contrib.user_auth.password_validation.UserAttributeSimilarityValidator. Check your AUTH_PASSWORD_VALI 
Python :: how to find left top width and height on an image using python 
Python :: iterating over the two ranges simultaneously 
Python :: student notebook (finish), INB (finish), Food and Fitness log (log necessary), debate speech (finish) 
Python :: Python Write to File Way01 
Python :: Python List Comprehension: Elegant way to create Lists 
Python :: repeating a program in python 
Python :: Indices may also be negative numbers, to start counting from the right:Indices may also be negative numbers, to start counting from the right: 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =