dimanche 4 janvier 2015

Condition with pass statement

I'm trying to figure out how to check if line contains some substrings or not, if it does, print that string. If it doesn't, do nothing. For this do nothing thing, I found that there is a statement in Python that just holds space and does nothing, which is pass so I used it. but the result is all strings are being printed no matter the condition.



try:
string = line.split(',')
if string[0] != 'Aa' or string[0] != 'Bb':
pass
print string

Aucun commentaire:

Enregistrer un commentaire