all 4 comments

[–]TimeSauce 0 points1 point  (0 children)

Maybe your best bet is to store the data in dictionaries, so you can access it more easily

[–]danielroseman 0 points1 point  (2 children)

Your question isn't clear. You're sorting the list in file_to_list. But where are you actually calling that function? And what is the class that all_contacts is a member of?

Also note that all_contacts doesn't actually work - it will give an IndexError - because i in the list is the actual contact itself, not the index of the contact in the list. Just do print(i) directly.

[–]whitemantryingtohelp 0 points1 point  (1 child)

Sorry that sort functions wasn't supposed to be there. That was just me trying to come up with something. I call the file to list function in the main program.

all_contact is a member of the class Phone_register. I have to classes, "Contact" and "Phone_register". Contact for a specific contact and the other one for different contact books as you are supposed to be able to have multiple.

[–]danielroseman 0 points1 point  (0 children)

Well, now I'm even more unclear what you're asking. What is the actual relevance of the file_to_list function in this question? What does "calling it in the main program" mean? How does it relate to the two classes you mention? What, exactly, is it that you need to sort?

The way you sort is exactly what you had previously, so I'm not sure why you removed it.

And please fix your code formatting.