I am trying to run a program to look at a .txt file and if, else depending on the content
I thought would be
Searhterms = [A, B]
with('output.txt') as f:
if ('A' and 'B') in f.read():
print('mix')
eLif ('A') in f.read:
if ('B') not in f.read:
print('ONLY A')
elif ('B') in f.read():
if ('A') not in f.read:
print('ONLY B')
else:
if ('A' and 'B') not in f.read:
print('NO AB)
But if A and B present it works, but if only one it skips to the else. I am getting more confused about the longer I look at this.
Aucun commentaire:
Enregistrer un commentaire