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.
"Everyone says it's so clever!" Well, because it is clever. That minor issue could be fixed by replacing x with any number, e.g.,
template = '(111) 111-1111'
;number += '1'
Yah...This function will accept (xxx) xxx-xxxx as a valid phone number. Everyone says it's so clever! lol
Seriously not trying to be a smart aleck here. It seems like you've just improved an inefficient approach. You're level 3 so beyond me python-wise. What made you choose this approach over ord()?
Agreed. Clever yes. But how can an incomplete solution be a best practice?
Really like the efficiency. Nice one.
I think the first two list comprehensions are easy enough to read. My only thought was, it's iterating throught the source list twice just to break it into evens and odds.
Agreed. In any test where letters appear, there are other problems like too long and/or missing parens or dash. They need to isolate the problem of a non-digit appearing where there should be a digit.
Similar to ost-k's solution. It gives a false positive when a string with a literal '?' appears where there should be a digit. e.g. (333) ?22-1111
I like the idea, but a false positive would result if a string were submitted with a literal 'x' where a digit should appear.