Nov-21-2017, 03:10 PM
thanks guys for the quick help, much appreciated!
I have now replaced "participants" with the participant names from a database table:
Any tips on how to the handle the data coming from the db before the match works?
I have now replaced "participants" with the participant names from a database table:
import psycopg2 as p import re conn = p.connect ("dbname='participants_db' user='postgres' host= 'localhost'") cur = conn.cursor() cur.execute("select participant_name from participants") names = cur.fetchall() paid = ('Betinna', 'Amelia') match = 0 for name in names: for namepaid in paid: if name == namepaid: match += 1 print(match)
Output:0
If I print the names it looks likes this:print(names)
Output:[('Amelia',), ('Alden',), ('Bettina',), ('Billy Ray',), ('Bodean',), ('Bucephelus',), ('Buddy',), ('Casey',), ('Charlton',), ('Cleavon',), ('Cletus',), ('Clyde',), ('Cooter',), ('Daisy',), ('Doc',), ('Duke',), ('Elrod',), ('Georgina',), ('Homer',), ('Huck',), ('John Boy',), ('Percy',), ('Quinn',), ('Robbie',), ('Stella',)]
Process finished with exit code 0
I have tried to strip the names first but that didn't change the result.Any tips on how to the handle the data coming from the db before the match works?