Reputation: 537
stb_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
passive_boxes_list = []
active_boxes_list = set(stb_list) - set(passive_boxes_list)
print active_boxes_list
I have got two lists. The number is going to be added into the passive_boxes_list
dynamically (1-16).
How I can subtract stb_list
from passive_box_list
.
For example: if passive_boxes_list = [1 , 2 , 3]
then active_box_list
should be:
active_boxes_list = [4, 5,6, 7, 8, 9, 10, 11, 12, 13,14,15,16]
Upvotes: 0
Views: 539
Reputation: 507
You should use the List Comprehension feature.
So you should have something like active_boxes_list = [x for x in stb_list if x not in passive_list]
Hope this help !
Upvotes: 3
Reputation: 574
You can try this:
list = [1,2,3,4,5,6,7]
bleh=[1,2,3,10]
for x in bleh:
if x in list:
del list[list.index(x)]
print list
Upvotes: -1