vendredi 1 mai 2020

If statement that checks if personal number has the expected number of digits//PYTHON

So i have to write a code that checks if personal number has 13 digits,if it has more or less it must raise ValueError,so i tried smth like this but it isnt working as intended

def jmbg(self,value):
    if len(str(value)) < 13 and len(str(value)) > 13:
        raise ValueError("Personal number must have 13 digits!")
    self.__jmbg = value

Aucun commentaire:

Enregistrer un commentaire