Level 9 : What will be the output of the following Python code?


A = [[1, 2, 3],
     [4, 5, 6],
     [7, 8, 9]]
[A[i][i] for i in range(len(A))]

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