40
Last seen 4 days ago
Member for 9 years, 10 months, 19 days
Difficulty Advanced
Hi, you can replace lines 5-10 with:
return ','.join(list_phrases).replace('right', 'left')
More
Hi, you do the same thing len(phrases) times, why?
def left_join(phrases):
output = ",".join(phrases)
output = output.replace('right', 'left')
return output
# is enough.
# And now get rid of output variable as you don't need it:
return ",".join(phrases).re
More
Hi, what's the point of the for loop? You do the same thing len(args) times.
# this is enough:
def checkio(*args):
if not args: return 0
return max(args) - min(args)
More
Hi, ... good, evil... that's funny :) but line 10 isn't:
return ",".join(curse) # is enough
More
Hi, there's some redundancy in your code:
1. You don't need to iterate over whole `data`. One `isSmall`, `isCaps`, `isLower` True, you don't need to continue.
2. You don't need to check each condition in every iteration.
3. `if...else` of lines 5 and 15 is redundant.
def checkio(data):
More
Hi, you could shorten it :)
~~~~
class Friends():
def __init__(self, connections):
self.connections = list(connections)
def add(self, connection):
if connection not in self.connections:
self.connections.append(connection)
return True
return F
More
Hi, one comment on this. You could write:
return sum(a != b for a, b in zip(n, m))
instead of:
count = sum([1 for a, b in zip(n, m) if a != b])
return count
More
Hi, you don't need the data variable as you can return it directly:
return [i for i in data if data.count(i) != 1]
Tip: Feel free to remove the comments :)
More
Hi,
1. What is the point of allcaps variable names? (In fact you don't need any of these variables.)
2. _ad_ lines 6, 7: Look at _str.join()_.
3. Look at slices in python:
return s[1:] # is enough.
More
Hi,
1. look at _filter()_.
2. __str__ in Python is immutable so it is not a good choice for accumulating values.
More
Hi,
1. i>= is already a bool so if...else is redundant:
return i >= 1 # or even return i > 0
2. Once you've found a pair, it does not make sense to continue. So you can move the return inside the if and omit the _i_ variable:
for every in words_set:
if every.endswith(tuple(word
More