Oct-14-2020, 09:05 PM
once a class is made how to I add contacts to it in the future with input as apposed to manually inputting the code for example lets say I wanted to add john doe with inputs from a user and store it instead of doing it manually also I want to be able to store a couple so setting john to a variable and grabbing data from that list wouldn't work, also is there a way to keep that stored data if I need to rerun the program I have seen code for address books however the data thats stored in a list is lost once the program is re ran
class Contacts: contactCont= 0 def __init__(self, first_name,last_name, email): self.first_name = first_name self.last_name = last_name self.email = email Contacts.contactCont +=1 def display_contact(self): print("First Name : ", self.first_name,", Last Name: ",self.last_name, ", Email: ", self.email) def name(self): n = self.first_name, self.last_name return n def email(self): e = self.email return e john = Contacts("john", "Doe", "[email protected]")