49
Awesome Team
Philippe Cholet
https://github.com/Philippe-Cholet
Last seen 3 hours ago
Member for 6 years, 2 months, 27 days
Difficulty Advanced
I was a math teacher in France for two years. I'm currently reconverting to IT, I'm here to improve my Python skills, and practice English.
I just propose a clarification of your code. I did not test it but it should work.
```python
from typing import List
def checkio(game_result: List[str]) -> str:
for xo in 'XO':
# check rows
for row in game_result:
if row == 3 * xo:
return xo
More
Use global variables is usually a bad idea, like here. Honestly it should NOT have pass tests. You only pass them because of "check" part work, and little tests did not warn you about it.
assert isometric_strings('add', 'egg') == True
dict == {'a': 'e', 'd': 'g'}
assert isometric_strin
More
Note that `for each,i in zip(str1, range(len(str1)))` and `for i,each in enumerate(str1)` are equivalent.
More
`num%2==0` is already a boolean True or False, you can return it.
def is_even(num: int) -> bool:
return num%2 == 0
More
Note that when I published this I could not put it in **creative** category where it clearly belongs.
More
Note: Here, `max` would be enough by itself (because isoformat is sortable by design), but it would be easy to change this solution to consider other datetime formats, something like:
get_latest = functools.partial(max, key=lambda s: datetime.datetime.strptime(s, '%H:%M %d/%m/%Y'))
More
@FromSnakeToPython Glad you liked the task. I enjoyed solving the task algorithmically more than manually.
More
You can annotate with nearly whatever you want, but here `int` annotation is not useful, and `list` annotation is (useless and) just wrong in the sense that "map" returns an object that is not a list at all.
"max" returns an integer (because "lnumber" is an iterable of integers), hence no need to c
More
About the first, first... what about list comprehension? Second, I'm pretty sure it should not work. It counts the number of email addresses with "." or "+" in the name part. Plus, case would matter, and duplicates would be counted multiple times.
```python
def unique_emails(emails: list[str]) -> i
More
`text == text.upper() or len(text) == 0` is already a boolean True/False, just return it.
No need of `len(text) == 0` since `'' == ''.upper()`.
return text == text.upper()
More
I would use "for/else" instead of "flag". What do you think?
for i in range(1, 101):
for j in range(4):
if i % prime[j] != attempts[j + 1][0]:
break
else:
return [2, i]
More
**EDIT:** in the arguments are of the **same** lengths.
More
Compare with `>` already give a boolean, you can just return the (boolean) comparison:
return items.count(True) > items.count(False)
More
You don't need "nonlocal" here.
In a new example, define variable "s" inside "g" is okay, but we can't use the "s" outside for it.
>>> def f(n):
s = []
def g(i):
s = s + [i**2]
for i in range(n):
g(i)
return s
>>> f(5)
Traceback
More
I think the "checkio" function should receive only one “step info” each time and process it, instead of giving the entire history, and a coroutine is a good way to do just that. Plus, it's a rare occasion to use `typing.Generator` in a meaningful way.
More
As the mission author, I receive emails about new solutions and saw the title of your solution and I'm glad you liked my task. =)
More
If you are reading this solution and asking yourself why this solution can even be publish (the function signature being clearly incorrect), it's because:
1. The mission (at the very beginning) did not have the second parameter which was latter added (to make it really different from another palind
More