Refined Luhn algorithm in Python so that it is functional