40
Last seen 4 days ago
Member for 9 years, 10 months, 19 days
Difficulty Advanced
Hi, try to look at [__set__](https://docs.python.org/3/library/stdtypes.html?highlight=set.intersection#set-types-set-frozenset) in Python. In fact you need to return a sorted set intersection.
def checkio(first, second):
first = set(first.split(","))
second = set(second.split("
More
Hi, there's a _str.join()_ function, so you don't need the for loop. And consider that __str__ is immutable in Python is immutable.
return "".join(i for i in text if i.isupper())
# or:
return "".join(filter(str.isupper, text)
In fact you don't need the _if_ as what it checks is a pr
More
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,
1. comments make it less readable.
2. it should be `letter not in m_text`.
3. you don't need `pangramtext`:
for letter in string.ascii_lowercase:
...
More
Hi,
1. You don't need `alpha_..._list` as you could `text.upper()` or `text.lower` and import `ascii_lowercase` or `ascii_uppercase`.
2. etc...
More