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