I’ve been searching around for some time for this, but have still not found an answer, maybe its got some thing to do with regular expressions, but i think there should be a simple answer that I am missing here. It seems very trivial to me … here goes:
On the python interpreter I get:
"abc" in "abc123"
as True.
I want it a command that returns a False. I want the entire word to be matched.
Thanks!
If you want to do a plain match of just one word, use ==:
If you’re doing
'abc' in ['cde','fdabc','abc123'], that returns False anyway:The reason
'abc' in 'abc123'returns true, from the docs:So for comparing against a single string, use ‘==’, and if comparing in a collection of strings,
incan be used (you could also do'abc' in ['abc123']– since the behaviour ofinworks as your intuition imagines whenyis a list or collection of sorts.