Level 1 : What will be the output of the following Python code?


l=[1, 0, 2, 0, 'hello', '', []]
list(filter(bool, l))

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