Posted on 28th April 2025|40 views
How to subtract two lists in python?
Posted on 28th April 2025| views
It is very simple to subtract two lists, just follow this example
li1 = [3, 3, 3]
li2 = [2, 2, 2]
result = []
zip_object = zip(li1, li2)
for li1_i, li2_i in zip_object:
result.append(li1_i-li2_i)
print(result)
Output:
[1, 1, 1]