Why is this output False? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why is this output False?

print (bool([]))

22nd May 2017, 10:07 PM
Kacy Colledge
Kacy Colledge - avatar
2 Answers
+ 1
because it is empty. empty == none. none == false.. This applies to strings, sets, dicts, lists, etc..
22nd May 2017, 10:18 PM
LordHill
LordHill - avatar
0
Hi, [] is an empty array so not exist then bool([]) = false [0] isn't empty and return one value (=0), then bool([0]) = true
22nd May 2017, 10:21 PM
MBZH31
MBZH31 - avatar