40
Last seen 4 days ago
Member for 9 years, 10 months, 19 days
Difficulty Advanced
Hi, don't use "\\" if it's not necessary. Put your expression in () instead e. g.:
grid = ([tuple([0]) * (len(grid[0]) + 2)]
+ [tuple([0]) + i + tuple([0]) for i in grid]
+ [tuple([0]) * (len(grid[0]) + 2)])
There are redundant [] on the last line:
return sum(
More
Hi, fwx and swx are redundant.
f = lambda w: Counter(w.replace(' ','').lower())
return f(first_word) == f(second_word)
More
Hi, extract the pattern from line 4, 5 and make it a function:
f = lambda w: collections.Counter(w.replace(' ', '').lower())
return f(first_word) == f(second_word)
More
Hi, good one. It's much more pythonic than your previous solutions. Two comments:
1. You should change the title a bit: "I love comprehensions!!!" :) Generators and comprehensions don't behave in the same way. (check this [blog post](http://python-history.blogspot.co.uk/2010/06/from-list-comprehens
More
Hi, there's an alternative approach. _str.join()_ first and then use _str.replace()_.
More
Hi, nice one :) Can you make it a one-liner? :) First step is to remove the redundant _result_ variable.
More
Hi, you can use * for unpacking _date1_ and _date2_:
return abs(date(*date1) - date(*date2)).days
More
Hi, the last if and all the == True tests are redundant:
return a and b and c and len(data) > 9
def checkio(data):
# If the string is not long enough you don't need the whole for loop
if len(data) < 10: return False
# a, b and c are bool values
More
Hi,
1. _bin()_ return a __str__, so str() is redundant.
2. __str__ has count method, so the for loop is redundant.
More
Hi,
1. Comments makes it hard to read.
2. What's the reason for this assignment: ref_list = string.ascii_lowercase? ascii_lowercase is just a string.
3. __set__ has _set.add()_ method so you don't need to use |=.
4. The last if is redundant:
return len(new_set) == len(ref_list)
P. S.: Yo
More
Hi, lambda is redundant. _key_ expects a function and _abs()_ is a function, so:
return sorted(number_array, key=abs) # is enough
More
Hi, don't use _sum_ as a variable name. It's a built-in function. Look at documentation for [_int_](https://docs.python.org/3.4/library/functions.html#int).
More
Hi, this is a misuse of _(x)range_. Look at extended slices:
array[::2] # even elements
More