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