diff --git a/native-datatypes.html b/native-datatypes.html index 07a773b..e3c755c 100644 --- a/native-datatypes.html +++ b/native-datatypes.html @@ -505,15 +505,18 @@ KeyError: 'db.diveintopython3.org' ... 1024: ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']} >>> len(SUFFIXES) 2 ->>> SUFFIXES[1000] +>>> 1000 in SUFFIXES +True +>>> SUFFIXES[1000] ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] ->>> SUFFIXES[1024] +>>> SUFFIXES[1024] ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'] ->>> SUFFIXES[1000][3] +>>> SUFFIXES[1000][3] 'TB'
    -
  1. As with lists, the len() function gives you the number of items in a dictionary. -
  2. 1000 is a key in the SUFFIXES dictionary; its value is a list of eight items (eight strings, to be precise). +
  3. Like lists and sets [FIXME-xref], the len() function gives you the number of keys in a dictionary. +
  4. And like lists and sets, you can use the in operator to test whether a specific key is defined in a dictionary. +
  5. 1000 is a key in the SUFFIXES dictionary; its value is a list of eight items (eight strings, to be precise).
  6. Similarly, 1024 is a key in the SUFFIXES dictionary; its value is also a list of eight items.
  7. Since SUFFIXES[1000] is a list, you can address individual items in the list by their 0-based index.