Python all items in list of lists true -


made table of true & false, , i'd check if true. used all() before, reason below fail miserably.

data = [[false, false, false],  [false, false, false],  [true, true, true],  [true, true, true]]  print(all(data)) >>> true 

why happening?

all not check bools in each sublist. each of non-empty lists truthy.

to check all items in all sublists true, should do:

all(x lst in data x in lst) # -> false 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -