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'
len() function gives you the number of items in a dictionary.
-1000 is a key in the SUFFIXES dictionary; its value is a list of eight items (eight strings, to be precise).
+len() function gives you the number of keys in a dictionary.
+in operator to test whether a specific key is defined in a dictionary.
+1000 is a key in the SUFFIXES dictionary; its value is a list of eight items (eight strings, to be precise).
1024 is a key in the SUFFIXES dictionary; its value is also a list of eight items.
SUFFIXES[1000] is a list, you can address individual items in the list by their 0-based index.