On 12/02/2013 03:25 AM, Byron Ruffin wrote:
The following program works and does what I want except for one last problem I need to handle. The program reads a txt file of senators and their associated states and when I input the last name it gives me their state. The problem is "Udall". There are two of them. The txt file is read by line and put into a dictionary with the names split. I need a process to handle duplicate names. Preferably one that will always work even if the txt file was changed/updated. I don't want the process to handle the name "Udall" specifically. For a duplicate name I would like to tell the user it is not a unique last name and then tell them to enter first name and then return the state of that senator.
What I would do, on data storing: * use last name as key as long as it works (meaning no duplicate last name) * else, try disambiguating with first name * else, store multiple statess (if both first and last names are equal) On data retrieval, follow the same logic. Denis _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor