r/learnpython • u/bkabartsy • Sep 26 '24
Empty strings - am i tripping?
>>> '' in 'abc'
Truecan someone explain? (python 3.12.6)
1
Upvotes
r/learnpython • u/bkabartsy • Sep 26 '24
>>> '' in 'abc'
Truecan someone explain? (python 3.12.6)
15
u/theWyzzerd Sep 26 '24 edited Sep 26 '24
Why would this not be true? Every string has an empty string in it. If
""is in""why shouldn't it also be in "a"?Think of it this way -- if a string is the set of characters "abc" what are you left with if you drop "a" and "b" and "c" from the string? You're left with "", which means it was in string "abc" all along.