I'm trying to write a simple if statement but I don't know why it's not working, I'm using vscode and python extension tried to disable python extension and auto save in vscode to see if it what causes the problem but that didn't resolve the problem.
so I must be doing something wrong here is my code:
Not working if gold is found it returns true, but if diamonds found it returns false!
import re
cave = 'high qualaity diamonds have been found '
match = re.search(r'\bhigh\b\s\bqualaity\b', cave)
if match and ('gold' or 'diamonds') in cave:
print(True)
else:
print(False)
same as the above one:
if (match) and ('gold' or 'diamonds') in cave:
print(True)
else:
print(False)
Not working too always return True weather the word is found or not:
if match and 'gold' or 'diamonds' in cave:
print(True)
else:
print(False)
same as above:
if (match) and ('gold') or ('diamonds') in cave:
print(True)
else:
print(False)
Aucun commentaire:
Enregistrer un commentaire