I'm solving a problem described in English and because I didn't learn to code in English, it's difficult for me to understand what the guide want me to do. I'll be appreciated if anyone would like to explain for me.
The full question is here. My question is if the list maintained in the question is the LIST in Python. If so, the created class seems useless. How can I use the overridden ==?(literally I don't know which two should be compared in this case) I don't know what to do next.
Here's what I've done.
def __init__(self,fn,ln,num):
self.firstName=fn
self.lastName=ln
self.idnumber= num
def insert(self):
newfirstname=input('First Name: ')
newlastname=input('Last Name: ')
newidnumber=input('ID Number: ')
personnew=Person(newfirstname,newlastname,newidnumber)
persons.append(personnew)
# def __eq__():
# def __greater__():
# def str():
filepath=input('the path of the file is:')
n=input('how many lines are required:')
n=int(n)
persons=[]
f=open(filepath,'r')
for i in range(n):
print(f.readline())
person=Person(f.readline().split()[0],f.readline().split()[1],f.readline().split()[2])
persons.append(person)
When I input n=2
, the output is not the first and the second line.
Looking forward to someone to help and thank you in advance.