Level 1 : What is the output of this nested list comprehension?


matrix = [[1, 2], [3, 4], [5, 6]]
result = [[num for num in sublist if num % 2 == 0] for sublist in matrix]
print(result)

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