#Purpose: create a program that reads the customer files and determines the person’s age. # Then display info in letter format. from datetime import date def get_customer_info(): #open file customer_file = open("customers.txt", "r") lines = customer_file.readline() for lines in customer_file: name = lines[0] street = lines[1] city = lines[2] state_zip = lines[3] dob = lines[4].split("/") pet = lines[4].rstrip("\n") age = calculate_age(age) discount = get_discount(age) customer_file.close() #get the vendor based off of the pet the user has animals = ["Cat","Dog","Horse","Fish"] vendors = ["Bertha's Kitty Boutique","K9 Supplies","Saddle & Tack Shoppe","Aquariums 'N' Stuff","Pet-R-Us"] if(pet in animals): vendorIndex = animals.index(pet) else: vendorIndex = 4 vendor = vendors[vendorIndex] customer_file.close() def calculate_age(birthDate): #function calculates the customers age. today = date.today() age = today.year - birthDate.year - (today.month, today.day) < (birthDate.month, birthDate.day) return age def get_discount(age): #this function deteremines the customer's discount based off their age discount = 0 if(18 <= age <= 25): discount = 20 elif(26 <= age <= 35): discount = 15 elif(36 <= age <= 45): discount = 10 elif(46 <= age <= 60): discount = 5 elif(60 <= age): discount = 25 return discount #format letter def letter(name, street, city, state_zip, dob, pet, discount): #format letter letterFormat = open("Letter.txt","w") #saving the file name with the name Letter.txt format the letter into another text file. letterFormat.write(name,"\n") letterFormat.write(street,"\n") letterFormat.write(city,",") letterFormat.write(state_zip,"\n\n") letterFormat.write("Dear Valued Customer:\n\n") letterFormat.write(vendor, "Happy Birthday! You are eligible for a ", str(discount), "% discount at") letterFormat.write(".\n\nHappy shopping,\n") letterFormat.close() print(letterFormat) get_customer_info()I've changed it up a bit and now I am getting this error: age = calculate_age(birthDate)
NameError: name 'birthDate' is not defined
and I'm sure it will do the same with the other varuable in the get_customer_info() for discount how could I use these functions to work with variables?