Level 1 : What will be the output of the following code ?


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

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