So I was looking for questions and came across this recent question
The answer for it is very simple but the one thing I noticed is that it actually did return SPAM
for exact match
So this snippet of code
text = 'buy now'
print(text == 'buy now' in text) # True
returns True
and I don't get why
I tried to figure out by placing brackets in different places and
text = 'buy now'
print(text == ('buy now' in text)) # False
returns False
and
text = 'buy now'
print((text == 'buy now') in text) # TypeError
raises TypeError: 'in <string>' requires string as left operand, not bool
My question is what is happening right here and why is it like that?
P.S.
I am running Python 3.8.10 on Ubuntu 20.04