Skip to content

Instantly share code, notes, and snippets.

@revolunet
Created August 18, 2011 19:20
Show Gist options
  • Save revolunet/1154911 to your computer and use it in GitHub Desktop.
Save revolunet/1154911 to your computer and use it in GitHub Desktop.
Valider un numéro de sécurité sociale [INSEE] en Python
def validInsee(insee, cle):
# http://fr.wikipedia.org/wiki/Numero_de_Securite_sociale#Unicit.C3.A9
# gestion numeros corses
insee = insee.replace('A', 0)
insee = insee.replace('B', 0)
reste = int(insee) % 97
return ((97 - reste) == int(cle))
@JeromeHoen
Copy link

JeromeHoen commented Jan 17, 2023

def validInsee(insee, cle):
    # http://fr.wikipedia.org/wiki/Numero_de_Securite_sociale#Unicit.C3.A9
    # gestion numeros corses
    insee = insee.replace('2A', '19')
    insee = insee.replace('2B', '18')
    reste = int(insee) % 97
    return ((97 - reste) == int(cle))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment