Membership testing for dictionary keys

The membership tests for dictionaries using the in and not in operators work on the keys:

>>> symbols = dict(
... usd='u0024', gbp='u00a3', nzd='u0024', krw='u20a9',
... eur='u20ac', jpy='u00a5', nok='kr', hhg='Pu', ils='u20aa')
>>> symbols
{'jpy': '¥', 'krw': '₩', 'eur': '€', 'ils': '₪', 'nzd': '$', 'nok': 'kr', 'gbp': '£', 'usd': '$', 'hhg': 'Pu'}
>>> 'nzd' in symbols
True
>>> 'mkd' not in symbols
True

 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset