Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python subtract one list from another

# Subtract list1 from list2 (find only items not in both lists)
list1 = [2, 2, 2]
list2 = [1, 1, 1]
difference = []   # initialization of result list

zip_object = zip(list1, list2)

for list1_i, list2_i in zip_object:
    difference.append(list1_i-list2_i) # append each difference to list

print(difference)
Comment

subtract one list from another python

 c = [x for x in a if x not in b]
Comment

PREVIOUS NEXT
Code Example
Python :: decode base64 with python 
Python :: python opencv open camera 
Python :: drop a column from dataframe 
Python :: read data from yaml file in python 
Python :: django setup allowed hosts 
Python :: schedule asyncio python 
Python :: check pip installed packages inside virtualenv 
Python :: download image python 
Python :: python sort list in reverse 
Python :: pygame.set_volume(2.0) max volume 
Python :: pandas groupby get all but first row 
Python :: how to split string with comma in python 
Python :: python temporaty files 
Python :: pandas read csv unnamed 0 
Python :: space to underscore python 
Python :: parcourir une liste par la fin python 
Python :: sqlalchemy validation 
Python :: playsound 
Python :: error bar plot python 
Python :: Get Key From value in dictionary 
Python :: sorting pandas dataframe like excel 
Python :: get first element list of tuples python 
Python :: python selenium save cookies 
Python :: remove n from string python 
Python :: python join two lists as dictionary 
Python :: How to perform insertion sort, in Python? 
Python :: python turtle shooting game 
Python :: python logging to file 
Python :: how to change icon in pygame 
Python :: python ls directory 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =