dimanche 5 décembre 2021

Python if statement doesn’t work with me? [closed]

I want to check if the keys less than or greater than 10 My Code :

phones = {"1111111111": "Mohammed", "2222222222": "Ali", "3333333333": "Rami"}


def check(n):
    for n in phones.keys():
        if len(n) > 10 or len(n) < 10:
            print('This is invalid number')
        else:
            print("OK")
        break


check("1")

The output is "OK" while the length of the n is less than 10 where is the mistake exactly? and what's the difference between len(n) > 10 or len(n) < 10 and 10 < len(n) < 10 Thanks

Aucun commentaire:

Enregistrer un commentaire