B Bích Hạnh Member Sep 20, 2021 #1 What will be the output of the following Python code? Code: l=[1, 0, 2, 0, 'hello', '', []] list(filter(bool, l)) A. Error B. [1, 0, 2, 0, ‘hello’, ”, []] C. [1, 0, 2, ‘hello’, ”, []] D. [1, 2, ‘hello’]
What will be the output of the following Python code? Code: l=[1, 0, 2, 0, 'hello', '', []] list(filter(bool, l)) A. Error B. [1, 0, 2, 0, ‘hello’, ”, []] C. [1, 0, 2, ‘hello’, ”, []] D. [1, 2, ‘hello’]
T Tam ca New member Sep 20, 2021 #2 Answer: d Explanation: The code shown above returns a new list containing only those elements of the list l which do not amount to zero. Hence the output is: [1, 2, ‘hello’]. Upvote 0 Downvote
Answer: d Explanation: The code shown above returns a new list containing only those elements of the list l which do not amount to zero. Hence the output is: [1, 2, ‘hello’].