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 :: keras read image 
Python :: make column nullable django 
Python :: md5 hash python 
Python :: discord.py how to give a user a role 
Python :: months of the year python list 
Python :: make beep python 
Python :: pyqt display math 
Python :: add empty row to pandas dataframe 
Python :: python check variable is tuple 
Python :: get the system boot time in python 
Python :: check pip installed packages inside virtualenv 
Python :: python get everything between two characters 
Python :: two input number sum in python 
Python :: python draw polygon 
Python :: plt plot grid on 
Python :: python sort 2d list 
Python :: python truncate to integer 
Python :: django querset group by sum 
Python :: knn classifier python example 
Python :: playsound 
Python :: Set column as index with pandas 
Python :: django staff required 
Python :: how to iterate pandas dataframe 
Python :: python datetime to utc 
Python :: get certain columns pandas with string 
Python :: panda datetime ymd to dmy 
Python :: tkinter app icon 
Python :: how to find second maximum element of an array python 
Python :: how to compare current date to future date pythono 
Python :: delete the duplicates in python 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =