17
Last seen 15 days ago
Member for 3 years, 4 months, 17 days
Difficulty Normal
Perhaps you could skip the whole part after the if?
is_majority = lambda i: i.count(True)>i.count(False)
I think just this would suffice, no need to compare twice.
More
Good job. Are you missing the '+' at the end of 'asap' and 'urgent' on purpose? You 've put one on the help. (Actually, it doesn't matter, because one letter at the end still completes the word and validates... just asking why one and not the others)
More
I had the same idea, but I didn't know how to write it so concisely. I learned something, thanks
More
Well I had the same idea, sorting and emptying the set, to minimize loop rounds. I like this for not creating an extra list (I used sorted()) and the while , pop() are more clear. Why not use str.endswith() in the conditional?
More
To add to what @attilagerendi said, sometimes is conceptually more correct: I, as a function, have this job to do (Find Nth power of the element with index N, as this mission asks). So if I get the wrong parameters, it's an error, not a decision I have to make.
(Kind of nitpicking here, but thought
More
I think is more correct to use
text[0].upper()
not
text[0].capitalize()
More
You could skip the
reverse=True
and the minus in -e by putting a minus in front of numbers.count(e), like this
key=lambda e: (-numbers.count(e), e))
More
Clever one, skips the same-word check. I did something similar, by emptying the set with each iteration.
More
Nice solution. Just a minor thing, I would put the conditions like this:
"first in word and word.find(first) == word.find(second) - 1"
If not in word, I 'm done with it, no more comparisons
More
good job. Perhaps in the multiplication you could use
array[-1]
instead of
array[len(array)-1]
Also, why use
while n <= len(array)-1:
the same result, and a little cleaner I think
while n < len(array):
More
Nice attempt, and I see it is working.
Perhaps you should go easy on the comments a bit, don't need to comment
# imcrements index 1
index += 1
I 'm just learning myself, but I must tell you that your code feels like C. I can't give you some solid proposals or exact ways to write
More
Nice! Pretty clear logic and implementation
Guess I have to study re a little more
More
You 're in for much more trouble than is needed..
Why are you replacing "left" with "right"? It isn't asked.
You 're checking three times the same thing (ok with a variation, if it is at the end)
if "right" in list_phr[i]:
if list_phr[i].endswith("right"):
n
More