Browse Source

Dict

pull/3/head
Jure Šorn 5 years ago
parent
commit
0b54db91c0
1 changed files with 4 additions and 2 deletions
  1. 6
      README.md

6
README.md

@ -58,12 +58,14 @@ Dictionary
collections.defaultdict(<type>) # Creates a dictionary with default value of type.
collections.defaultdict(lambda: 1) # Creates a dictionary with default value 1.
collections.OrderedDict() # Creates ordered dictionary.
dict(<list>) # Initiates a dict from list of key/value pairs.
```
```python
dict(<list>) # Initiates a dict from list of key-value pairs.
dict(zip(keys, values)) # Initiates a dict from two lists.
{k: v for k, v in <dict>.items() if k in <list>} # Filters a dict by keys.
```
### Counter
```python
>>> from collections import Counter

Loading…
Cancel
Save