0

Use of and/or with lists in Python

How are and/or to be interpreted when we only pass lists to them? I came across the following in a Python challenge: y=[0,0] y=[1,1] b=x and y print(not b)

10th Feb 2020, 12:48 PM
Raffaele
Raffaele - avatar
1 ответ
+ 3
A list is True if something's in it, and False if it's empty. (Same for other collections.) So x and y are both true, because they contain stuff. b will become the last checked item. So b is y after that. This means that b is also True. not True is False.
10th Feb 2020, 1:12 PM
HonFu
HonFu - avatar