Level 9 : What will be the output of the following Python code?


l=[1, 0, 2, 0, 'hello', '', []]
list(filter(bool, l))

Author: KaivalyaG | Tags: filter-function | 1859+ Python FAQs | Share
control-statement | variable | boolean | integer | bitwise-operator | escape-operator | file | else-statement | expression | bitwise | __all__-attribute | global-variable | anchors-(^,-$) | async | keyword | exception-handling | arithmetic-expression | arbitrary-arguments-(*args,-**kwargs) | classes | comment | built-in-modules | __future__ | fabs-function | sorting-and-ranking | arithmetic-operation | string | scientific-notation | benefit | round | class-and-instance-variable | set-operation | built-in | encoding | introduction-to-python | sorted | append | class | stack | condition | type-conversion-and-casting | using-os-and-pathlib-modules | static-method | syntax-error | handling-missing-values-(fillna,-dropna) | thread | slice | recurssion | dictionary-methods | exception | virtual-environment | membership-operators-(in,-not-in) | file_handling | compute | interpreter | class-decorators | identifier | global | using-join()-and-is_alive()-methods | comprehension | introduction-to-threads | while-and-for-loop | oop | context-manager | creating-and-starting-threads | memory-management | logical-operator | min-max-function | namespace | zip | slicing | reading-and-writing-files | parameter | string-formatting | matplotlib | matrix-list-comprehension | working-with-dates-and-times | pep | python-history | module | threading | while-loops | with-statement | string-iteration | quantifiers-(*,-+,-?,-{}) | walking-through-directories-using-os.walk() | nested-loop | package-management | sum-function | literal-characters-and-special-characters | strings | string-methods | python-operators | touples | goto-function | input-function | datetime.date,-datetime.time,-datetime.datetime | aggregating-data-with-functools.reduce() | library | conditional-statement | data-type | constructor | comparison | assignment-operators | expand-tab | filter | inheritance | data-type | boolean-masking | class-and-inheritance | unit-testing | parsing-with-strptime | loop-control | round-function | application | list-comprehension | creating-custom-modules | regular-expressions | operand | conditional-statements | random | list-comprehension | __init_subclass__ | time-series-with-pandas | indentation | access-modifier | list | factorial-function | binary-operation | logical-operator | sorting | python_version | bitwise-operator | sets | file-handling | head-and-tail | iterator | assert | reading-and-writing-large-files-efficiently | decorator | advanced-file-operations | why-use-multiprocessing-over-threading?-(gil) | test-discovery | syntax | integers | mapping-function | yield | version-check | functions | working-with-file-paths | floats | sys-module | heap-memory | tuple-methods | decimal | list-vs-tuple | command-line-parsing | overflow | choice | operator-overloading | python-repl | zfill-function | math-copysign | identity-operator | type-conversion | defining-functions | dataframe-and-series-objects | update | name-mangling | object-attribute | data-structure | logical-operators | managing-directories-with-os-and-shutil | global-variable | inherit | collection | typeerror | thread-synchronization | set | counter-function | basic | memory | namedtuple | max-min | sys | array | floating-point-precision | tuples | call | default-mutable-argument | data-structures-in-python | input | data-structure | string-slicing | range | datatype | shallow-copy | difference-between-threads-and-processes | copy | loops | dictionaries | turtle | file-handling | reading:-read(),-readline(),-readlines() | formatting-with-strftime | single-inheritance | center | dictionary-comprehensions | string-method | matrix | staticmethod | numeric | filtering-and-indexing | built-in-function | global-keyword | lambda | mutable | working-with-binary-files-(rb,-wb) | exception-handling | joining-and-merging-dataframes | while-else-loop | methods | complex-number | debugging | functional-programming | descriptors | operations | data_structure | identity-operator | error-handling | feature | multiple-inheritance | regex | control-flow | map-function | input-function | function-and-scope | version | functional-programming | dicts | complex | thread-safe-data-structures-(queue.queue) | conditional-statement | sum() | boolean-and-non-boolean | immutability | design-principle | multiple-except-blocks | multithreading | mysql | asyncio | multiple-inheritance | attribute | method-overloading | print-statement | function-argument | numpy | built-in-function | data-types | higher-order-function | data-type-conversions | polymorphism | overriding-methods | installation | syntax-error | def | writing:-write(),-writelines() | string-slicing | generators | operator | python-module | else | datetime | swapping | string-manipulation | objects | using-lists-as-stacks | operator-and | collections | multiprocessing | docstring | regular-expression | rollback | raise | counter | filter-function | control-flow | working-with-temporary-files-using-tempfile | operator-or | implementation | while-loop | destructor | string-concatenation | binary | precedence-and-associativity | syntaxerror | list-comprehensions | oops | default-arguments | split | tuple | statement | join | list-slicing | list-method | logical-operation | odd-number | recursion | virtual-environment | encapsulation | list-methods-and-slicing | pandas | lambdas | type_conversion | deep-copy | asyncio-module | indexing | init | data-structures | zip-function | tuple-unpacking | intering | class-and-object | assignment-operator | list,-set,-and-dictionary-comprehensions | loop-control-statements | print | format | operators | using-else-and-finally | software-design | python-syntax-and-structure | opening-files-(open()) | booleans | conversion | indexing:-loc-vs-iloc | mathematics | list-mutation | invalid-list | identity-operators-(is,-is-not) | immutable-data-type | error-handling | pickling--unpickling | int | type-conversion | directory-operations | for | magic-method | key-value-pairs | id-function | lambda-functions | using-map()-for-transformations | error | introduction-to-multiprocessing | pseudocode | formal-and-actual-parameter | method | return-statement | iterable | using-assertions-(assertequal,-assertraises) | using-yield-in-functions | python-django | string-method | lambda-function | precedence | import-method | using-the-threading-module | mathematical-function | python | list-operation | generators-in-python | pass | function | postfix | lists | math | exponentiation | match | loop | iterators | list-join | frozenset | random-function | string-formatting | raise-statement | generator | gil | enumerate() | min-function | dictionary | list-indexing ...