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