On 04/08/15 23:09, Quiles, Stephanie wrote:

def main():
     found = False

     search = input("Enter a name in the file for info: ")

     infile = open("emails.dat", "r")
     name = infile.readline()
     while name != '':
         email1, email2, phone, phone2 = (infile.readline())
         name = name.rstrip("\n")

You should probably do this immediately after reading the name

         if name == search:
             print("name: ", name)
             print("Email1, alternate email, phone, alternate phone", email1, 
email2, phone, phone2)
             print()
             found = True

Note that if name does not equal search you will go round this loop forever (or at least until you finish reading the file) because you don't change the name.

     name = infile.readline()

I suspect this line was supposed to be inside the while loop?


See if that helps?

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to