string - Why when x(t) is empty the output is ['a','b','a']. Python -


def x(t):     return '' in t  def t(alist):     blist = alist[:]     in blist:         if x(i) == false:             alist.remove(i)     print alist  t(['a','b','c']) 

the output ['a','b','a'] supposed [].

but if change following:

def x(t):     return 'd' in t 

the output [].

an empty string "in" string. expected.

>>> '' in 'hello' true >>> '' in '' true >>> 'a' in '' false >>> 'a' in 'abc' true >>> 'd' in 'abc' false 

Comments