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