18
Last seen 9 months ago
Member for 9 years, 6 months, 20 days
Difficulty Normal
You may write if-else in a one line, for example:
return text if text[-1] == '.' else text + '.'
More
Looks good, maybe will be better change 5 strings of code in one, for example:
return array[n]**n if len(array) >= (n+1) else -1
And a little refactoring you can check len(array) without more or equal but only more, e.g.:
return array[n]**n if len(array) > n else -1
More
You may write in one line:
return True if all(elem == list[0] for elem in list) else False
More
You may change a some part of code for more readable.
For example,
you may check to %15 firstly and return str(number) in the else block code:
if number % 15 == 0:
return 'Fizz Buzz'
...
else:
return str(number)
More
Interesting approach, I recommend to look on builtin library `string` with property `ascii_lowercase`
More
Interesting solution, But I think with `while` will be more clear
More
Why do you use `list.sort(data, key = lambda k: k["name"])` ?
You can use only this one `list.sort(data, key = lambda k: k["price"],
reverse = True)`.
list.sort - not obviously will be nice avoid this construction.
More
You can use all logic inside try/except.
try:
st = text.index(begin) + len(begin)
except:
st = 0
And the same for end case.
More
try solve this task with [list comprehension](https://docs.python.org/3.4/tutorial/datastructures.html#list-comprehensions)
More
You used the extra checking ( len(data) == 0 ).
In prerequisite is written that **0 < len(data) < 1000**
More
Try using sort-method and length/2.
And you can don't use 2.0 when divide two numbers.
More