I want to output difference two tuple and remove one element on tuple
a = [(1,2),(2,3),(3,3)]
if (1,2) in a:
## how to remove (1,2) on tuple
i need output [(2,3),(3,3)]
how to do it?
Thanks,
Answer
Other way, you can use del
>>> a = [(1,2),(2,3),(3,3)]
>>> del a[a.index((1,2))]
>>> a
[(2, 3), (3, 3)]
>>>
or using .pop
>>> a = [(1,2),(2,3),(3,3)]
>>> a.pop(a.index((1,2)))
(1, 2)
>>> a
[(2, 3), (3, 3)]
>>>
No comments:
Post a Comment