[Tutor] find pickle and retrieve saved data

Quiles, Stephanie stephanie.quiles001 at albright.edu
Mon Aug 3 05:04:08 CEST 2015


 how do i go about being able to add a feature to search for individual entries that have been saved into that dictionary or else tell me that the name I entered is not found? 

Here is the code that i have so far…

import pickle
def main():
    infile = open("emails.dat", "rb")
    emails = pickle.load(infile)
    infile.close()
    name_search = input("Enter a name in the file for info: ")

    for name in emails:
        
        if name[0] == name_search:
            print("This is the info: ", info)
        return emails
    else:
        print("Entry not Found! Try again.")
main()


thanks for all the help and suggestions this is really helping me in trying to figure this out! 

Stephanie


More information about the Tutor mailing list