40
Last seen 1 day ago
Member for 9 years, 11 months, 4 days
Difficulty Advanced
Hi,
1. Look at _set()_.
2. Line 11 is not Pythonic and you can replace lines 11-13 with:
return not my_dict
More
Hi, you can use `*` to unpack `date1` and `date2` e. g.:
d1 = datetime.date(*date1)
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, Python is not C. I'm not sure if this is speedy, have you measured it?
More
Hi, you could use _sum()_ with _generator expression_ instead of `for` loop and `result` variable.
More
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, you don't need that "else cascade" in the end.
1. Instead of `'a' <= x <= 'z'` you can use `x.islower()`.
2. Instead of `'A' <= x <= 'Z'` you can use `x.isupper()`.
3. Instead of `x in b` you can use `x.isdigit()`.
4. Line 14: `if number and u_letter and l_letter:`
etc.
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, you can use _generator expression_ with _sum()_:
return sum(x in text.lower() for x in words)
More