11
Last seen 4 years ago
Member for 10 years, 2 months, 17 days
Difficulty Normal
Playing Python
Pretty clear one.
You can also simplify first 3 lines with:
nets = list(set(net.split('-')) for net in network)
More
You could avoid creating additional `t` variable and just:
for x in text.lower():
...
More
Nice one-liner.
Using _True_ instead of _(a,b)_ might look cleaner:
any(True for a, b in permutations(words_set, 2) if a.endswith(b))
More
Very original recursion solution.
This technique is described here: [Extended Iterable Unpacking](https://www.python.org/dev/peps/pep-3132/)
It's unique Python3 feature:
https://docs.python.org/3/whatsnew/3.0.html#new-syntax
More
The only drawback here is that it catches ALL exceptions (which is considered as bad practice), while it's better to catch specific exception type.
https://docs.python.org/2.7/howto/doanddont.html#except
More
Illustrates Python principle: "**It's easier to ask for Forgiveness than Permission**" (EAFP).
This differs how we usually write the code in other programming languages (C, Java, PHP, Ruby, etc) with many condition checks, if-else statements.
https://docs.python.org/2/glossary.html#term-eafp
More