For example I have a list that looks like this:
l = [(1,2),(1,3),(4,1)]
how can I remove item (1,3) without knowing the index of the item?
I tried l.pop((1,3))
but I got this error message: TypeError: an integer is required
Answer
l = [(1,2),(1,3),(4,1)]
print(l) #[(1, 2), (1, 3), (4, 1)]
l.remove((1,3))
print(l) #[(1, 2), (4, 1)]
No comments:
Post a Comment