16
Safwan Samsudeen
Last seen 2 years ago
Member for 3 years, 6 months, 22 days
Difficulty Normal
Great solution. Is there any advantage to use this method over `statistics.median`? I saw your [other solution](https://py.checkio.org/mission/median/publications/veky/python-3/statistics/), really elegant, but is there any advantage to use this over that?
More
I didn't think of using a generator, I used a list comprehension inside of the `sum` function. Thanks!
More
Why `OrderedDict`? Is there any advantage - other than meaning - in using it over `dict`?
More
Why `OrderedDict`? Is there an advantage other than the semantic one in using it over `dict`?
More
You can also use the `textwrap` core module here. `textwrap.wrap(a, 2)`, will, as the docs say
> Wraps the single paragraph in text (a string) so every line is at most width characters long. Returns a list of output lines, without final newlines.
```
import textwrap
def split_pairs(a):
a += "
More
Instead of `'abcdefghijklmnopqrstuvwxyz'`, you could use the `string.ascii_lowercase` string.
```py
>>> import string
>>> string.ascii_lowercase
'abcdefghijklmnopqrstuvwxyz
```
More
Great logic. Only one thing - my linter's statement - Unnecessary "else" after "return". Also, what does `L` stand for?
More
Is there any reason to use `OrderedDict` over the normal `dict` class now, considering that `dict` is ordered now?
More
You can use the `textwrap` core module here. `textwrap.wrap(a, 2)`, will, as the docs say
> Wraps the single paragraph in text (a string) so every line is at most width characters long. Returns a list of output lines, without final newlines.
```
import textwrap
def split_pairs(a):
a += "_" if
More
There is a string method called lstrip which strips the passed parameter from the left side of the string (or spaces if a parameter isn’t passed). So `number.lstrip(0)` will return the number without any zeros in its left side. You can use this and check the `len` of `number.lstrip(0)`, and subtract
More
There is a string method called lstrip which strips the passed parameter from the left side of the string (or spaces if a parameter isn’t passed). So `number.lstrip(0)` will return the number without any zeros in its left side. You can use this and check the `len` of `number.lstrip(0)`, and subtract
More
Great solution. But I used `math.prod([int(char) for char in str(number) if char != '0'])`. Is there any disadvantages in that?
More
You could just do `return sum(array[::2]) * array[-1] if array else 0`. Good solution though.
More
There is a string method called lstrip which strips the passed parameter from the left side of the string (or spaces if a parameter isn’t passed). So `number.lstrip(0)` will return the number without any zeros in its left side. You can use this and check the `len` of `number.lstrip(0)`, and subtract
More
You can use the `textwrap` core module here. `textwrap.wrap(a, 2)`, will, as the docs say
> Wraps the single paragraph in text (a string) so every line is at most width characters long. Returns a list of output lines, without final newlines.
More
I used `len(set(elements)) == 1 or len(set(elements)) == 0` instead of `len(set(elements)) <= 1`. Great solution.
More
Instead of
```py
if p_date[14:] == '01':
v_m ='minute'
else:
v_m ='minutes'
```
You could do this:
```py
v_m = 'minute' + ('s' if p_date[14:] != '01' else '')
```
Similar with the hour step
```py
v_h = 'hour' + ('s' if p_date[11:13] != '01' else '')
```
More