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