[Tutor] Finding Match in nexted tuple

Tim Johnson tim at johnsons-web.com
Wed Apr 21 18:44:02 EDT 2004

Let's say I have a list of zip codes returned from a MySQLdb query
zip_code_list = (('84536',), ('85003',), ('85004',), ('85006',),
                 ('85007',), ('85008',))
# and I want to look for a match for a value like '85004'
# I can think of doing it like this: (untested)

zzip = '85004'
for Z in zip_code_list:
    if zzip in Z:
      print 'found'

Is there a quicker or more pythonesque way to do this?
<gr>Even tho' I *think* I know what I'm doing I tend to
    get really interesting answers from you'all.

Tim Johnson <tim at johnsons-web.com>

More information about the Tutor mailing list