jeudi 5 février 2015

which way of checking item in list is correct

which way of checking item in list is correct?



>>> lst1 = ['A', 'B']
>>> if 'C' not in lst1: print 'Hi'
...
Hi


or



>>> if not 'C' in lst1: print 'Hi'
...
Hi


to me the first one looks correct but still in doubt ? not sure if this has been asked by someone on SO before if so please link


Aucun commentaire:

Enregistrer un commentaire