I need some help, please

Hi

How can I make the method Remove work. It only says the name dosen’t exist. I want the user to be able to type in a last name and then want the person that has that name to be deleted from the list. Then I want the file to be updated. I don’t know how to do that. But it doesn’t work even to remove a person. It only says that the name dosn’t exits.
I have tried to make this work for a long time now. Please can someone help me.

class Person:
    def __init__(self, firstname, lastname, birthday, adress):
        self.firstname = firstname
        self.lastname = lastname
        self.birthday = birthday
        self.adress = adress
 
class Register:
    def readFromFile(self):
        global name_list
        name_list = list()
        name_file = open("names.txt", "r")
        line = name_file.readline()
        while line != "":
            firstname = name_file.readline()
            lastname = name_file.readline()
            birthday = name_file.readline()
            adress = name_file.readline()
            name_list.append(Person(firstname, lastname, birthday, adress))
            line = name_file.readline()
        name_file.close()

    def Remove(self):
        name = raw_input("Enter the last name of the person you want to delete ")
        for i in name_list:
            if name == i.lastname:
                name_list.remove(i)
                print "Removed", i.firstname, i.lastname
                return
            else:
                print "The name doesn't exist."
    def lista(self):
        for i in name_list:
            print i.firstname, i.lastname, i.birthday, i.adress   

You need to strip the EOL character from i.lastname for the for the conditional statement to be true.

for i in name_list:
            if name == i.lastname[:-1]:
                name_list.remove(i)

or

for i in name_list:
            if name == i.lastname.strip():
                name_list.remove(i)

If you ever saw the output from print “Removed”, i.firstname, i.lastname, it would have been a dead give away

Removed Test
User