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