import pickle def inputdate(): print "This functions lets you enter a date and checks it" valid = False while not valid: mo = input("Please enter the month as an integer from 1 to 12: ") day = input("Please enter the day as an integer as appropriate: ") yr = input("Please enter the year as a four digit integer: ") if (type(mo) == int) and (type(day) == int) and (type(yr) == int) and\ (1 <= mo <= 12) and (1 <= day <= 31) and (0 <= yr <= 9999): print "Your date ",mo,"/",day,"/",yr," is valid" return day, mo, yr else: print "Please re-enter a date that is valid" print "This program will let the user enter birthdate, age and name for multiple people " keepgoing = True howmany = 0 outfile = open("dateage.txt","w") print type(outfile) while keepgoing: name = raw_input("Please enter the name of the person whose birthday you will enter: ") print "Now you can give me ",name,"'s birthday " d, m, y = inputdate() print "Finally, ",name,"'s age is: ", age = input() numyears = 2011 - y if numyears - 1 <= age <= numyears: print "age is reasonable for given birthdate " else: print "age is not reasonable for given birthdate " yn = raw_input("If you wish to enter more names, type Y. If not, type N ") if yn == 'N': keepgoing = False pickle.dump(d, outfile) pickle.dump(m, outfile) pickle.dump(y, outfile) #pickle.dump(m, y, outfile) #only accepts one input at a time pickle.dump(age, outfile) pickle.dump(name, outfile) howmany += 1 print type(outfile) outfile.close() outfile = open('dateage.txt','r') print "After open for r",type(outfile) print "howmany is ",howmany while howmany > 0: day = pickle.load(outfile) mo = pickle.load(outfile) yr = pickle.load(outfile) ag = pickle.load(outfile) nm = pickle.load(outfile) print "The data stored in outfile is:" print " ",nm," age ",ag\ ," with birthday ",mo,"/",day," / ",yr howmany -= 1 outfile.close()