40
Last seen 4 days ago
Member for 9 years, 10 months, 19 days
Difficulty Advanced
Hi, you could use _timedelta.days_ instead of _date.toordinal()_:
(date(*date1) - date(*date2)).days
More
Hi, when you _str.join()_ first and then _str.replace()_ after, you can do the replacement in one step.
More
Hi,
1. instead of `x.isalpha() and x == x.upper()` you can use `x.isupper()`.
2. instead of concatenating __str__ with `+` you can use _str.join()_.
return "".join(x for x in text if x.isupper())
More
Hi, in fact you don't need `w` as `[]` because it is enough the count the words:
w = 0
words = words.split()
for x in words:
if x.isalpha():
w += 1
if w == 3:
return True
else:
w = 0
return False
More
Hi,
1. What's wrong with `len(args)`?
2. Why not:
return len(args) < 2
3. Line 5: You don't need `*`.
More
Hi, you can use `*` to unpack `date1` and `date2` e. g.:
d1 = datetime.date(*date1)
More
Hi,
1. `lambda` is redundant.
2. _list()_ is redundant as _str_ is iterable.
You could write:
return "".join(filter(str.isupper, text))
More
Hi,
1. You don't `if...else`. You can directly return the condition.
2. Look at _all()_ and _generator expressions_.
3. An alternative to _re_ is to use _str.islower()_, _str.isupper()_, _str.isdigit()_/
More
Hi, you don't need `new_list` variable, you could return list comprehension directly.
More
Hi, look at _any()_ and _all()_, e. g.:
return all(chr(ch) in text for ch in range(97,123))
More
Hi,
1. It is not necessary to parenthesize `if` conditions.
2. You don't need `number` variable:
for i in str(number):
3. Look at _reduce()_ in _functools_ module.
More
Hi,
1. _sum()_ is a built-in function, do not redefine it.
2. You could write:
for i in range(len(grid)):
for j in range(len(grid[0]):
3. You could use _abs()_ instead of _fabs()_. That way you could omit `import math`.
I've played with your code, result is [here](http://www.checkio
More