What Is The Optimal Way To Parse These Strings In Python?
Using Python and given the following unique items, what is the optimal way to find the pair that matches the two names combined? For example, how would you find the tuple that corresponds to the string
For background, the right index will only ever have ~5 options (of strings length 3 or 4) while the left may have >100.
(AMB, BNB), (AMB, BTC), (AMB, ETH), (ARK, BTC), (ARK, ETH), (ARN, BTC), (ARN, ETH), (AST, BTC), (AST, ETH), (BAT, BNB), (BAT, BTC), (BAT, ETH), (BCC, BNB), (BCC, BTC), (BCC, ETH), (BCC, USDT), (BCPT, BNB), (BCPT, BTC), (BCPT, ETH), (BNB, BTC), (BNB, ETH), (BNB, USDT), (BNT, BTC), (BNT, ETH), (BQX, BTC), (BQX, ETH), (BTC, USDT), (BTG, BTC),
l = [('AMB', 'BNB'), ('AMB', 'BTC')] d = dict() for s in l: d[''.join(s)] = s def find_name(key): return d[key] if d.get(key) else None print(find_name('BNBBTC'))
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module