15
Jing Meng
Last seen 1 year ago
Member for 10 years, 8 days
Difficulty Normal
(FYI) By using the "ternary" operator in python (syntax: `exp1 if predicate else exp2`), the two if-then-set code blocks can be eliminated, e.g.
```
start_pos = 0 if begin not in text else (text.find(begin) + len(begin))
```
which make the code more compact, and *sometimes clearer* while *somet
More
I suggest this solution would serve *better* if the story itself gets extended/generalized/complicated (either as another story/problem, or described/defined in comment/doc string) such that modeling the problem as a interpolation process would become *natural*, in which case those who are not famil
More
By looking at the picture (the clock circled with 12-hour and 24-hour format numbers), the logic of deciding a.m./p.m. would become clearer.
Apart from that, note that the (hours == 12 and minutes == '00') branch in your code can be merged with the last else branch as their code block are identica
More
Upvote for the [operator.lt, operator.gt] trick, the idea didn't come up to me :D
Small advice: cache the fkey(temp_min) result cause the key function might be cpu/time-consuming.
More
Per the usage of all, u could replace with all(i.isalpha() for i in [words[i:i+3]]).
More