def id_number_checksum(gd):
 n = s = 0
 for c in (((gd['year'] + gd['month']) + gd['day']) + gd['serial']):
  tmp = ((((n % 2) and 1) or 2) * int(c))
  if (tmp > 9):
   tmp = sum([int(i) for i in str(tmp)])
  s += tmp
  n += 1
 if ((s % 10) == 0):
  return 0
 return ((((s // 10) + 1) * 10) - s)

def id_number_checksum ( gd ) : n = s = 0 for c in ( ( ( gd [ 'year' ] + gd [ 'month' ] ) + gd [ 'day' ] ) + gd [ 'serial' ] ) : tmp = ( ( ( ( n % 2 ) and 1 ) or 2 ) * int ( c ) ) if ( tmp > 9 ) : tmp = sum ( [ int ( i ) for i in str ( tmp ) ] ) s += tmp n += 1 if ( ( s % 10 ) == 0 ) : return 0 return ( ( ( ( s // 10 ) + 1 ) * 10 ) - s )
calculates a swedish id number checksum .