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