Browse Source

Counter

pull/10/head
Jure Šorn 5 years ago
parent
commit
33683bdbdb
1 changed files with 3 additions and 3 deletions
  1. 6
      README.md

6
README.md

@ -83,9 +83,9 @@ value = <dict>.pop(key) # Removes item from dictionary.
```python ```python
>>> from collections import Counter >>> from collections import Counter
>>> colors = ['blue', 'red', 'blue', 'yellow', 'blue', 'red'] >>> colors = ['blue', 'red', 'blue', 'yellow', 'blue', 'red']
>>> Counter(colors)
>>> counter = Counter(colors)
Counter({'blue': 3, 'red': 2, 'yellow': 1}) Counter({'blue': 3, 'red': 2, 'yellow': 1})
>>> <counter>.most_common()[0][0]
>>> counter.most_common()[0][0]
'blue' 'blue'
``` ```
@ -134,7 +134,7 @@ to_exclusive = <range>.stop
Enumerate Enumerate
--------- ---------
```python ```python
for i, <el> in enumerate(<collection> [, i_start]):
for i, element in enumerate(<collection> [, i_start]):
... ...
``` ```

Loading…
Cancel
Save