31
Andrey Solomatin
Last seen 1 year ago
Member for 11 years, 2 months, 9 days
Difficulty Normal
Code is not well formated, it is hard to read it.
**enumerate** has start argument.
you can use **itertools.zip_longest** instead of **zip**
More
Some python tips:
# if text[0] == ' '
if text.startswith(' ')
#if text[len(text)-1] == ' ': you can access last item by text[-1]
if text.endswith(' ')
More
You can get alphabet : **from string import ascii_lowercase**
No need to c.lower() it is already in lowercase by mission rules.
More
I did not see any benefits of **deque** in this case. You can use **list** and pop last added item.
More
You solution is potentialy wrong.
In precondition: string.ascii_letters + **string.punctuation**
Your **".,;:?!"** is not cover all punctuation
You can simplify you code by using None as split separator (https://docs.python.org/2/library/stdtypes.html#str.split)
You can zip message and scores. Or
More
PEP8: For sequences, (strings, lists, tuples), use the fact that empty sequences are false.
Yes:
if not seq:
if seq:
No:
if len(seq)
if not len(seq)
More
You should avoid to use magic numbers,
for letter in range(26):
if uppercase[letter] in data:
checks[2] = True
if lowercase[letter] in data:
checks[3] = True
you can use zip or xrange(len(iterable))
# xrange is almost same as range
More
This is worst usage of nested function. You just create it to use once and it does not use any arguments from outer scope.
More
Return **None, None** is good idea.
**enumerate** has start argument.
I don't sure that docstrings are useful at this case. Function and arguments has good names.
Lines 5, 12, 29 has no dot at the end.
You have two blank lines in function body (35,36).
More
**{g(p//n+d*k,p%n+e*k)** I usualy produse such text by random typing instead of **lorem ipsum** :)
More
Use of **global** is bad practice, it is easy to make checkio to have no side effects.
You can start position from 0, in that case **p+1** will became **p** and **p+2 => p+1**
Please follow PEP8 for better readability.
More
> \# This one use ()
Tuple? Or unnercessary parenthesis?
This comment is confusing.
More
Good code, easy to read and understand.
You can join *near_cells*, *can_go* and *possible_moves*, to one function that will return list of possible cells.
You use class and side effects instead of return, but still passes visited as argument.
""" Style
"""
More
while ' ' in text: text = text.replace(' ', ' ')
You can just split by space and filter empty values. (You split it any way.)
Better to use '\n'.join() instead of string concatenation.
More
if you repeat something a lot of times, then you doing it wrong. You need to use some kind of iteration.
More
**maximize_sum** almost do all you need in this task, just need to add two conditions **if len==1 return max(lst[0], 0) if not len return 0**
More