Howw to prevent the duplication of any value in a column within a CSV file (python)

darnold darnold992000 at yahoo.com
Wed Apr 27 11:49:09 EDT 2016


potential_passengers = ['bob','john','sue','wendy','chris','bob','jen','wendy']
accepted_passengers = set()

for name in potential_passengers:
    print('checking on {}...'.format(name))
    if name not in accepted_passengers:
        accepted_passengers.add(name)
        print('welcome aboard, {}!'.format(name))        
    else:
        print('i am sorry, we have already accepted a {}.'.format(name))
    print()        
            

HTH,
Don         



More information about the Python-list mailing list