I currently have a textfile with saved data just as:
surname1
name1
number1
address1
surname2
name2
number2
address2
...
I want to use this textfile to create instances in my class:
class Contact(object):
def __init__(self, surname, name, number, address):
self.surname = surname
self.name = name
self.number = number
self.address = address
I need a function that can read from the textfile, use 4 rows as attributes for a new instance, append that instance to a list & then do it again for the next 4 rows and so on...how can this be done?