Python Forum
homework - banking system
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
homework - banking system
#1
i need to search customers by their last name in order to allow the admin user to have access to the customers account.
i have already created the admin search but can sombody tell me why the search_customers_by_name is not working Sad
 def search_admins_by_name(self, admin_username):
        #STEP A.2
        found_admin = None
        for a in self.admins_list:
            username = a.get_username()
            if username == admin_username:
                found_admin = a
                break
        if found_admin == None:
            print("\n The Admin %s does not exist! Try again...\n" %admin_username)
        return found_admin 
        
    def search_customers_by_name(self, customer_lname):
        #STEP A.3
        found_account = None
        for a in self.accounts_list:
            lname = a.get_last_name()
            if lname == customer_lname:
                found_account = a
                break
            if found_account == None:
                print("\n The account does not exist! Try again...\n" %customer_lname)
            return found_account
Reply
#2
What do you mean by "not working"? Do you get an error message or does the method not give a result? Or the wrong result? In the last two cases: examine the accounts_list. Does it contain an element with the last_name you are looking for?
Reply
#3
One obvious issue is that line 21 would be triggered every time through the loop. I think you only want it to say not found if it has looped through every account
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  homework - banking system Massimo16 1 4,690 Jan-12-2020, 03:56 PM
Last Post: ibreeden
  Banking system - transferring money 3DEN 2 8,870 Dec-13-2019, 09:13 AM
Last Post: 3DEN
  Homework Help - Simple Grading System Segovia 7 7,770 Jul-24-2018, 10:55 PM
Last Post: Segovia

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020