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