List of Numbers

Gerhard Haering gh at ghaering.de
Sat Apr 5 14:21:56 EST 2003


Simon Faulkner wrote:
> I have a list of about 5000 numbers in a text file - up to 14 digits
> each.
> 
> I need to check for duplicates.
> 
> What would people suggest as a good method?

Use the numbers as keys for a dictionary. Before inserting, check if 
such an entry already exists. If this key exists already, you have found 
a duplicate.

-- Gerhard






More information about the Python-list mailing list