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