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