Update formatting
This commit is contained in:
@ -7,7 +7,7 @@ lastUpdated: 2020-11-02T19:27:07+02:00
|
||||
|
||||
Returns the length of a string in bytes.
|
||||
|
||||
- Use `str.encode('utf-8')` to encode the given string and return its length.
|
||||
- Use `str.encode()` to encode the given string and return its length.
|
||||
|
||||
```py
|
||||
def byte_size(s):
|
||||
|
||||
@ -9,7 +9,7 @@ Creates a list of dates between `start` (inclusive) and `end` (not inclusive).
|
||||
|
||||
- Use `datetime.timedelta.days` to get the days between `start` and `end`.
|
||||
- Use `int()` to convert the result to an integer and `range()` to iterate over each day.
|
||||
- Use a list comprehension and `datetime.timedelta()` to create a list of `datetime.date` objects.
|
||||
- Use a list comprehension and `datetime.timedelta` to create a list of `datetime.date` objects.
|
||||
|
||||
```py
|
||||
from datetime import timedelta, date
|
||||
|
||||
@ -7,7 +7,7 @@ lastUpdated: 2020-11-02T19:27:53+02:00
|
||||
|
||||
Creates a dictionary with the unique values of a list as keys and their frequencies as the values.
|
||||
|
||||
- Use `collections.defaultdict()` to store the frequencies of each unique element.
|
||||
- Use `collections.defaultdict` to store the frequencies of each unique element.
|
||||
- Use `dict()` to return a dictionary with the unique elements of the list as keys and their frequencies as the values.
|
||||
|
||||
```py
|
||||
|
||||
@ -7,7 +7,7 @@ lastUpdated: 2020-11-09T23:56:11+02:00
|
||||
|
||||
Tests a value, `x`, against a testing function, conditionally applying a function.
|
||||
|
||||
- Check if the value of `predicate(x)` is `True` and if so return `when_true(x)`, otherwise return `x`.
|
||||
- Check if the value of `predicate()` is `True` for `x` and if so call `when_true()`, otherwise return `x`.
|
||||
|
||||
```py
|
||||
def when(predicate, when_true):
|
||||
|
||||
Reference in New Issue
Block a user