I'm developing a Python program to detect names of cities in a list of records. The code I've developed so far is the following:
aCities = ['MELBOURNE', 'SYDNEY', 'PERTH', 'DUBAI', 'LONDON']
cxTrx = db.cursor()
cxTrx.execute( 'SELECT desc FROM AccountingRecords' )
for row in cxTrx.fetchall() :
if any( city in row[0] for city in aCities ) :
#print the name of the city that fired the any() function
else :
# no city name found in the accounting record
The code works well to detect when a city in the aCities' list is found in the accounting record but as the any() function just returns True or False I'm struggling to know which city (Melbourne, Sydney, Perth, Dubai or London) triggered the exit.
I've tried with aCities.index and queue but no success so far.