Public feed #727555

Untitled

public python v1 · immutable
Raw Edit
·published 2007-10-06 03:57 UTC
rendered paste body
def verify_sin(sin):    '''verify_sin(str) - > boolean          Given a string argument returns True if the string entered represents      a valid sin number. Otherwise returns False. Also returns False if the     sin entered is not a string or if it is of the wrong length.'''        if ( type(sin) != str ):        return False        sin.replace('-','')        if ( len(sin) != 9 ):        return False        count = 0    sum1 = 0    sum2 = 0           for digit in sin:                                if count % 2 == 0 and count < 9:            sum1 += int(digit)            count += 1        if count % 2 != 0 and count < 9 and int(digit) * 2 < 10:            sum2 = sum2 + (int(digit) * 2)            count += 1        if count % 2 != 0 and count < 9 and int(digit) * 2 >= 10:            sum2 = sum2 + int(digit) * 2 / 10 + int(digit) * 2 % 10            count += 1    sum_final = 10 - ( ( sum1 + sum2 ) % 10 )    return str(sum_final) == sin[10]