17
Александр Зайцев
Last seen 1 month ago
Member for 7 years, 19 days
Difficulty Normal
1. The string does not need to be converted to a list, the string is already iterable.
2. You do not need to do an object tearing if int (num) == 0. readable will be:
if int (num)! = 0:
item * = int (num)
3. Also, the python has a well-defined construction - A = Y if X else Z
In this st
More
Using "**try except**" in this case is not very correct (bad style), and also slows down the algorithm. It is better to check whether the list is not empty with a construction -
## if not close_order
More
password = ''
dimension = len(cipher_grille)
for x in range(dimension):
password += ''.join([ciphered_password[i][j] for i in range(dimension) for j in range(dimension) if cipher_grille[i][j] == 'X'])
cipher_grille = [''.join([cipher_grille[i][j] for i in range(dimension - 1,
More
Why use pop ()? Changed array no further where not used.
You can get the last element using the index -1 (array [-1])
More
That there would not be a lot of nested if (it's harder to read) conditions you can unite using "and", "or"
More
An interesting solution)
The python has a function - isalpha(). With it would be more readable and shorter.
More
It was possible not to create a variable "resultado", but immediately return the result of sorting.
More
Conditions "if" could be done less
_if j + 3 <= size-1 and matrix[i][j] == matrix[i][j+1] == matrix[i][j+2] == matrix[i][j+3]:
return True_
With the rest by analogy)
So it turns out less nesting "if" and accordingly it becomes easier to read.
More
Use _catche_ as part of the logic necessary to calculate the result VERY BAD! In the block _catche_ there should be only error processing
More
Why compare with magic string variables (_if operation == "connection"_)? It's better to write _if operation == "connection"_
Also, you can not do internal _if_ and just _return x and y_
So there are fewer codes:)
More
следуй pip8 https://www.python.org/dev/peps/pep-0008/?
textLower-> text_lower
sum = sum + 1 -> sum+=1, sum - зарезерверированное слово, используй другое. например sum_worlds
отличное решение для c# кода
в питоновской концепции можно решить элегантней
создать список в котором будут хран
More
если нужен индекс при переборе используй enumerate()
for index, value in enumerate():
More
password = ''
dimension = len(cipher_grille)
for x in range(dimension):
password += ''.join([ciphered_password[i][j] for i in range(dimension) for j in range(dimension) if cipher_grille[i][j] == 'X'])
cipher_grille = [''.join([cipher_grille[i][j] for i in range(dimension - 1, -1,
More
Why create a list?
You can immediately check if there are any values in args and if not then return 0
Otherwise use min and max from args
More
password = ''
dimension = len(cipher_grille)
for x in range(dimension):
password += ''.join([ciphered_password[i][j] for i in range(dimension) for j in range(dimension) if cipher_grille[i][j] == 'X'])
cipher_grille = [''.join([cipher_grille[i][j] for i in range(dimension - 1,
More
Why are so many "if / elif"?
the resulting string is a function of strftime("%-d %B %Year %-H hours %-M minutes"), and then you make a replacement( so only two conditions are obtained)
More