I am constructing an if statement on Python that prints something when regex's match function founds a coincidence. I would like to know why the if statement works when my statement's condition is not a boolean (I think so).
import re
coincidence = re.match(r'\w{3}', 'abc')
if coincidence:
print('There\'s a match')
which yields:
"There's a match"
Why does it work?
Aucun commentaire:
Enregistrer un commentaire