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.
I would sat that using multiple
if
statements is a slightly better practice overif ... elif ... elif ...
whenever the condition for all of the ifs is both consistent and clearly exclusionary. In this case, both of those are met since it is an inate logical idea in programming that if a variable equals a character, then it cannot also equal a different character.Using only
if
statements makes the code sligtly easier to read, especially for those who use any of the braced langagues (Java, C#, JavaScript, etc) where you have to useif (condition) {...} else if (condition) {...} else if (condition) {...} else {...}
instead ofelif
.But I 100% agree that using a ternary instead of just returning an equality expression is not a best practice.
My appologies. New format is also available, and I belive preferred, in 2.7 as well.
See https://docs.python.org/2.7/library/string.html#string-formatting
Test Failurer: '1 ** b */ 1' should equal '1 * 1'
This seems like a typo in one of the internal tests. I believe the test is missing a slash ('/') between the stars. As it stands, the test is requiring that a single star be treated as the start of a comment.
This comment is hidden because it contains spoiler information about the solution
All tests pass except for this one:
Failing test: 144991 should equal 'Error 404'
Even forcing an
if int(x) == 144991: return 'Error 404'