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