def validate_nhs_number(num): s = str(num) if len(s) != 10: return False tot = 0 for i in range(9): dig = int(s[i]) tot += dig * (10-i) tmp = tot % 11 if tmp == 0: checksum = 0 else: checksum = 11 - (tot % 11) if checksum == 10 or checksum != int(s[9]): return False else: return True