31
Andrey Solomatin
Last seen 1 year ago
Member for 11 years, 2 months, 8 days
Difficulty Normal
V and S are bad variable names for python.
For multi line docstrings I prefer to start text from second line.
More
In line 4-5 you made some checks, but same checks will be done in line 7(inside endswith).
I did not test it but think that removing lines 4-5 will make you code to work faster.
More
you can use builtin function **len** instead of this lambda: **lambda x: len(x)**
see **str.endswith** in python docs
you can throw away lines 2 and 3, because **for i in []** will do no cycles.
More
Theres is function in standard library that do the same as **lambda e: abs(e)** you should use it instead of this lambda.
More
If you use variable once and in return statment, just return result
return eval('su' + 'm')(data)
More
str = '' -> shadow builtin function
if Num < 1 or Num > 3999: This check is not required. It makes code more bulky.
(Num, modNum) = divmod(Num, 10) -> Num, modNum = divmod(Num, 10)
numToRomanNum and checkio are two functions that do same job. It is bad design.
read about PEP8
More
You can omit last argument of reduce.
Pydocs: If the optional initializer is present, it is placed before the items of the iterable in the calculation.
More
line 3: http://www.checkio.org/forum/post/1618/proper-way-to-check-if-sequence-is-empty/
More
you can simplify expression: **if product == 0:** => **if product**
you can simplify you code by set product to 1 at line 2.
More
**pr = reduce(...** => **return reduce(...**
you can replace you lambda with **mul** from operator module
More
**map(int, [n for n in str(number) if n!='0'])** is very bad. You can do it in one pass, just convert to int inside list comprehension.
n0 is bad name for variable. I prefer to use **res** or **result** in such cases.
More
You can skip parenthesis:
if number % 5 == 0 and number % 3 == 0:
More
line 14: http://www.checkio.org/forum/post/1618/proper-way-to-check-if-sequence-is-empty/
More
no: **if len( args ) == 0** yes: **if not args**
no: **argslist = list( args ); argslist.sort()** yes: **argslist = sorted(args)**
Why you need abs?
More
You can use return on length fail.
if len(data) < 10:
return False
Check all function
return all((length, num, caps, low))
Please cleanup you code before publish, this comments are invalid.
# replace this for solution
# Some hints
# Just check a
More