+ 1

Why is this happening?

my_list = [False] print(bool(my_list)) #output: True

15th Nov 2020, 10:50 AM
Тирон Максим
Тирон Максим - avatar
1 Answer
0
Hi, You have the same with this. my_list = [False, "foo", "bar"] print(bool(my_list)) #output: True You can mix type in a list. So convert a list in a bool is equal to convert something in bool, and something in bool is true. If you want convert element, you have to select index of this element.
31st Jul 2021, 1:25 PM
Angus