Browse Source

Dict

pull/3/head
Jure Šorn 6 years ago
parent
commit
bb4b249fe9
1 changed files with 6 additions and 6 deletions
  1. 12
      README.md

12
README.md

@ -43,18 +43,18 @@ Dictionary
<dict>.update(<dict>)
```
```python
>>> a = [('x', 4), ('y', 5)]
>>> dict(a)
{'x': 4, 'y': 5}
```
```python
collections.defaultdict(<type>) # Creates a dictionary with default values.
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.
```
```python
>>> a = [('x', 4), ('y', 5)]
>>> dict(a)
{'x': 4, 'y': 5}
```
### Counter
```python
>>> from collections import Counter

Loading…
Cancel
Save