remove from a list of tuples according to the second part of the tuple in python -


contact. Delete ((Name, IP))

I have IP and it is unique I want to remove this tuple from contacts according to the IP and there is no need for the name.

I have just tried it contacts.remove ((pass, ip)) , but an error I encountered.

  contact = [name, ip] for name, IP if IP in contacts! = Removable_ip]  

or for x in xrange

  (lane (contact -1, -1, -1): if the contact [x]] [1 ] == Removable_ip: Dell contact [x] break # removable_ip is reportedly unique  

The first method is to rebinds in the newly created list contact is not included in it The second method updates the original list; del statement is being rolled under its feet.


Comments