Nov-09-2021, 05:35 PM
(Nov-09-2021, 04:21 PM)BashBedlam Wrote: So… my question is, why does python think that nothing or a zero length string IS in ‘abcdefg’?A empty string is a substring of every string.
>>> '' in 'hello' True >>> '' in 'h' True >>> '' in '' TrueThe easiest solution for your code is to add
list('abcdefg')
then do not need to test for empty string.>>> 'h' in list('hello') True >>> '' in list('hello') False