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