aneliabogeva

Optimized Banking System

Jul 15th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. class Bank_Account:
  2. def __init__(self, name, bank, balance):
  3. self.name = name
  4. self.bank = bank
  5. self.balance = float(balance)
  6.  
  7. command = input().split(' | ')
  8.  
  9. bank_account_list = []
  10.  
  11. while not command[0] == 'end':
  12. bank_account = Bank_Account(name=command[1],bank=command[0],balance=float(command[2]))
  13. bank_account_list.append(bank_account)
  14.  
  15. command = input().split(' | ')
  16.  
  17. for account in sorted(bank_account_list, key= lambda acc: (-acc.balance,len(acc.bank))):
  18. print(f'{account.name} -> {account.balance:.2f} ({account.bank})')
Add Comment
Please, Sign In to add comment