33
33
```
34
34
35
35
``` python
36
- sum_of_elements = sum (< list > )
37
- elementwise_sum = [sum (pair) for pair in zip (list_a, list_b)]
38
- sorted_by_second = sorted (< list > , key = lambda el : el[1 ])
39
- sorted_by_both = sorted (< list > , key = lambda el : (el[1 ], el[0 ]))
40
- flattened_list = list (itertools.chain.from_iterable(< list > ))
41
- list_of_chars = list (< str > )
42
- product_of_elems = functools.reduce(lambda out , x : out * x, < list > )
43
- no_duplicates = list (set (< list > )) # Does not preserve order
44
- no_duplicates_ordered = list (dict .fromkeys(< list > )) # Preserves order
36
+ sum_of_elements = sum (< list > )
37
+ elementwise_sum = [sum (pair) for pair in zip (list_a, list_b)]
38
+ sorted_by_second = sorted (< list > , key = lambda el : el[1 ])
39
+ sorted_by_both = sorted (< list > , key = lambda el : (el[1 ], el[0 ]))
40
+ flattened_list = list (itertools.chain.from_iterable(< list > ))
41
+ list_of_chars = list (< str > )
42
+ product_of_elems = functools.reduce(lambda out , x : out * x, < list > )
43
+ no_duplicates = list (dict .fromkeys(< list > ))
45
44
```
46
45
47
46
``` python
@@ -67,7 +66,6 @@ Dictionary
67
66
``` python
68
67
collections.defaultdict(< type > ) # Creates a dictionary with default value of type.
69
68
collections.defaultdict(lambda : 1 ) # Creates a dictionary with default value 1.
70
- collections.OrderedDict() # Creates ordered dictionary.
71
69
```
72
70
73
71
``` python
0 commit comments