Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Both of the
elif
can simply beif
. It's also more standard to writeif not isinstance(number, int)
.The
elif
isn't necessary in this case, it can just beif
FYI, the
all()
function returnsTrue
only if all the list elements evaluate toTrue
.However, you will also have to count there are four elements, so I like this solution. :)
If you want to catch anything and you don't care about what the actual exception was you can use:
If you need to check a value is between two numbers you can reduce it to:
The
if
statement is convertingresult
to some boolean value. You can do the same thing without theif
statement by simply casting:This solution is nice and simple but it would be better if the
REGEX
variable was named after what it was, rather than what it is. For example, naming itIP_REGEX
would be more approproate reuasable solution. :)This comment is hidden because it contains spoiler information about the solution
This is just showing off. This is not clean, easily maintainbly code.
This is actually better than all of the other solutions because your code doesn't need to contain the definition of what an IP is at all.
This comment is hidden because it contains spoiler information about the solution
I didn't like this one. It's confusing and very fiddly. There is no sense of achievement at the end.
This looks to be nice and clean because it is only two lines, but consider that putting 4 sepearte bits of information (the individual quanitities) onto separate lines. Spreading them over multiple lines may be longer but it is inherently clearer and better for version control when someone makes a change to a quantity.
This is a terribly verbose and confusing solution.