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


a = [[], "abc", [0], 1, 0]
print(list(filter(bool, a)))

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