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