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.
it's short, but the filter function call is equialent to [c for c in x if str.isdigit(c)] which has the disadvantage that it will go through the whole word and create an array even if there's only one digit and it can be the first character in the word. If we change the call to filter into this:
next(int(c) for c in x if c.isdigit()) this will create a generator which will in this usage will stop on first digit found...
@acaccia
OK I see now in the 2.7 documentation. My mistake, thanks for the help.
If iterable is a string or a tuple, the result also has that type; otherwise it is always a list.
@CrazyMerlyn:
Oops, didn't thought about it, my bad :p
@acaccia, a solution or spoiler should be marked spoiler even when discussing it on a solution thread.
While someone who hasn't solved this problem can't access the solution, the comment is still visible on the home page.
This comment is hidden because it contains spoiler information about the solution
How can
int
accept the result fromfilter
?int
requires a number or string, andfilter
returns a list.TypeError: int() argument must be a string, a bytes-like object or a number, not 'filter'
Test cases are incorrect