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