DeaD_EyE

Untitled

Nov 2nd, 2021 (edited)
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. class CoinError(ValueError):
  2.     """"
  3.    CoinError
  4.    """
  5.  
  6. coins = [
  7.     {"ID": 1, "Symbol": "ETH", "Name": "Ether"},
  8.     {"ID": 2, "Symbol": "SOL", "Name": "Solana"},
  9.     {"ID": 3, "Symbol": "BTC", "Name": "Bitcoin"},
  10. ]
  11.  
  12.  
  13. def get_symbol(symbol):
  14.     for coin in coins:
  15.         if coin.get("Symbol") == symbol:
  16.             return coin
  17.  
  18.     raise CoinError(f"Coin with symbol '{symbol}' does not exist")
  19.  
  20.  
  21.  
Add Comment
Please, Sign In to add comment