def create_account(self, account_type, account_number): ''' Creates and returns a new account object with the given account type and account number Takes two strings as parameters ''' # Try to retrieve an account with the same account number and, if it succeeds, we know # that number is already in use. account_number_exists = False try: Checking_Account.get(account_number=account_number) account_number_exists = True except: try: Savings_Account.get(account_number=account_number) account_number_exists = True except: try: Brokerage_Account.get_account(account_number) acount_number_exists = True except: pass # Throw exception if account number is already in use if account_number_exists: raise Exception("Account Number is already in use") # Create a checking account if that's the account type if account_type == "checking": acct = Checking_Account(account_number=account_number).save() # Create a savings account if that's the account type elif account_type == "savings": acct = Savings_Account(account_number=account_number).save() # Create a brokerage account if that's the account type elif account_type == "brokerage": acct = Brokerage_Account(account_number=account_number).save() # If we don't have a matching account type, raise an exception else: raise Exception("Invalid Account Type") return acct