dimanche 14 juin 2020

condition to check if the list include a string except the string that I want

I want to write a condition that check if the list has another string that is not '1' or '2'.
For example:

list = ['1', '2'] -> is True
list = ['1', '3'] -> is false

I tried something like that but it didn't work:

if list[0] is not '1' or list[0] is not '2' and list[1] is not '1' or list[1] is not '2':
    return False
else:
    return True

Help someone??

Aucun commentaire:

Enregistrer un commentaire