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


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

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