I am relatively new to Python (~5 months), so pardon my ignorance. I have been tasked with creating a program to do a few things.
First, I have a text file with information stored like the following:
name, street, city state zip, birthday, pet.
Second, my instructions include:
- Reading the text file and determine the age and based on the age, determine a discount. For instance, if the age is 18 -25, they receive a 5% discount.
- Match the pet preference with a vendor
I am utilizing classes for each of the attributes. I have a separate file for the class information which is indicated below. I have set/get methods for each attribute listed.
From information.py
class GetInfo:
def __init__(self,name,street,city,state,zipcode,birthday,pet):
self.__name = name
def set_name(self,name):
self.__name = name
def get_name(self):
return self.__name
At the end I have to write a letter for each individual. I can't figure out how to essentially keep the data separate in order to write the letter per individual. I will write each line using a .write(str) method. Here is my main program so far:
import information
import os
import time
CURRENT_YEAR = 2018
def main():
customerInfo = information.GetInfo(name,street,city,state,zipcode,birthday,pet)
tempFile = open('temp.txt','w')
with open('c.TXT') as customerList:
lines = customerList.readlines()
for line in lines:
tempFile.write( str(GetInfo.name) + '\n')
tempFile.close()
main()
For the vendor list I will have a dictionary such as:
vendors = {"Cat:CatCity"}
I am perplexed at my next step, while also receiving this error when trying to run the program:
"main.py", line 10, in main customerInfo = information.GetInfo(name,street,city,state,zipcode,birthday,pet)
NameError: name 'name' is not defined