Ad
  • Custom User Avatar

    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...