[Python Edinburgh] Comparing two Tuples

Dougal Matthews dougal85 at gmail.com
Wed Oct 20 16:03:58 CEST 2010


Random question for you all. I've got a solution but I don't think its that
intuitive, so I'm curious if there is a neater way.

What is the best to compare two tuples and see if they contain one or more
of the same items.

A = (1,2,3)
B = (3,4,5)
C = (6,7,8)

Where A would match B because they both have 3 and C wouldn't match either.

if <magic here>:
    print "One or more item is the same"
else:
    print "The tuples don't contain any of the same items"


Dougal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/edinburgh/attachments/20101020/a747a42a/attachment.html>


More information about the Edinburgh mailing list