def luhnCheck(value):
 arr = []
 for c in value:
  if c.isdigit():
   arr.append(int(c))
 arr.reverse()
 for idx in [i for i in range(len(arr)) if (i % 2)]:
  d = (arr[idx] * 2)
  if (d > 9):
   d = ((d / 10) + (d % 10))
  arr[idx] = d
 sm = sum(arr)
 return (not (sm % 10))

def luhnCheck ( value ) : arr = [ ] for c in value : if c . isdigit ( ) : arr . append ( int ( c ) ) arr . reverse ( ) for idx in [ i for i in range ( len ( arr ) ) if ( i % 2 ) ] : d = ( arr [ idx ] * 2 ) if ( d > 9 ) : d = ( ( d / 10 ) + ( d % 10 ) ) arr [ idx ] = d sm = sum ( arr ) return ( not ( sm % 10 ) )
the luhn check against the value which can be an array of digits .