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.
You're only asked to return True if n is a digit, which is what the solution does. Nowhere in the kata description does it say you have to use regex.
I would argue in any case that it's better practice to use built-ins for this instead of bringing in the overhead of the regex library where it's not required.
Pep8 recomends not to use complex compound statements, like if len(x for x in list) > len (y for y in range(6): return [x for x in list] if A else 0
This is fine i guess
submit your answer adding:
print("\n".join(map(str,n))
this shows which tests are passing or not
I tried with regex first and it failed one miserable test. I have no way to check which one, so I decided to take a shortcut. (=:
I - indentation.
@Erhytr how did you figure that out?
Thank you. I just saw this yesterday, and remembered when I coded, but forgot when I got here.
(I thought I was wrong, but I was mistaken.)
This comment is hidden because it contains spoiler information about the solution
so the test send just one character for numbers.
for example this number '321' is going to be evaluated as false due len != 1.
right?
to limit the length of the string for the condition since digit 0-9 is a character with the length of 1
I don't undestand the why the use len equals 1. if the len is for example 10 the expresions is not going to be evaluated.
somebody please explain me why the use of len(n)==1 in this case.
That's the beauty of it, as regex is not enforced ;-)
This doesn't employ RegExp at all. Although it passes the tests, it does not do what is asked.
Needs 'import future' to be compatible with Python 2.xx. Good solution though. Kudos
OMG Sweet I thought of isdigit but totally overlooked the use of len
Loading more items...