I understand the proper way to check multiple items in a list is to use any
and all
, like this.
A slow method is shown below in the second if-statement (if 'e' in lst and 'b' in lst
). However, the first if-statement below does not return any error, so what actually it is doing? i.e. what is the exact meaning of if 'e' and 'b' in lst
?
lst = ['a','b','c']
if 'e' and 'b' in lst:
print(1)
if 'e' in lst and 'b' in lst:
print(2)
>>> 1