I am using the following code but when I try and print the information from the list it gives the error "<main.person object at 0x0000016162A50940>" I am new to programming and can't find the solution as I don't even know the key terms to find this information.
I have been shown a similar post and have read through it and made some changes such as "Define repr but I am still stuck and when I add repr is now says "person() takes no argument". Would someone be able to give me some more guided and specific help. Thanks.
menu = ""
option = ""
class person:
def __init__(self, First, Second, Number,Address1, Address2, Postcode):
self.First = First
self.Second = Second
self.Number = Number
self.Address1 = Address1
self.Address2 = Address2
self.Postcode = Postcode
def new_Address(self):
print(self.First + " " + self.Second + " " + self.Address1 + " " + self.Address2 + " " + self.Postcode)
def __str__(self):
return f"{self.First} {self.Second} : {self.Number} : {self.Address1} : {self.Address2} : {self.Postcode} \n"
while option != "5":
option = input(" Main Menu\n1. Add new address \n2. Change existing address \n3. View all addresses in database \n4. View specific address \n5. Quit")
if option == "1":
print ("Adding new address...")
First = input("First Name ")
Second = input("Second Name ")
Number = input("Number ")
Address1 = input("Street ")
Address2 = input("Town ")
Postcode = input("Postcode ")
new_Address = person (First, Second, Number, Address1, Address2, Postcode)
Addresses.append(new_Address)
print("Address Added")
elif option == "2":
print("option 2")
elif option == "3":
print("All Addresses")
for new_Address in Addresses:
print(new_Address)
input("Press Enter to Continue")
elif option == "4":
print("option 4")
elif option == "5":
print("See you next time!")
break
else:
print("input not recognised. please try again...")```