Return none when user is not present

class UserDatabase:
def init(self):
self.users = []

def insert(self, user):
    i = 0
    while i < len(self.users):
        # Find the first username greater than the new user's username
        if self.users[i].username > user.username:
        i += 1
    self.users.insert(i, user)

def find(self, username):
    for user in self.users:
        if user.username == username:
            return user
    return "User not found"

def update(self, user):
    target = self.find(user.username), =,
def list_all(self):
    return self.users

I have modified the find function, whenever the user is not present it should return “User not found”
but it doesn’t return any value, please tell me where I am going wrong

  1. You could use append() instead of adding new user like this.
  2. How did you verify that the method doesn’t return anything?