Browse Source

List

pull/10/head
Jure Šorn 6 years ago
parent
commit
b9b7b0c573
1 changed files with 4 additions and 4 deletions
  1. 8
      README.md

8
README.md

@ -33,13 +33,13 @@ List
``` ```
```python ```python
sum_of_elements = sum(<list>)
sum_of_elements = sum(<collection>)
elementwise_sum = [sum(pair) for pair in zip(list_a, list_b)] elementwise_sum = [sum(pair) for pair in zip(list_a, list_b)]
sorted_by_second = sorted(<list>, key=lambda el: el[1])
sorted_by_both = sorted(<list>, key=lambda el: (el[1], el[0]))
sorted_by_second = sorted(<collection>, key=lambda el: el[1])
sorted_by_both = sorted(<collection>, key=lambda el: (el[1], el[0]))
flattened_list = list(itertools.chain.from_iterable(<list>)) flattened_list = list(itertools.chain.from_iterable(<list>))
list_of_chars = list(<str>) list_of_chars = list(<str>)
product_of_elems = functools.reduce(lambda out, x: out * x, <list>)
product_of_elems = functools.reduce(lambda out, x: out * x, <collection>)
no_duplicates = list(dict.fromkeys(<list>)) no_duplicates = list(dict.fromkeys(<list>))
``` ```

Loading…
Cancel
Save