r/learnpython • • Sep 26 '24

Empty strings - am i tripping?

>>> '' in 'abc'
True

can someone explain? (python 3.12.6)

1 Upvotes

27 comments sorted by

View all comments

4

u/This_Growth2898 Sep 26 '24

In the string 'abc', 'b' is between 'a' and 'c'.

In the string 'ac', '' is between 'a' and 'c'.

So, 'b' in 'abc' should be as true as '' in 'ac'.