Level 2 : What will this code output?


lst = [1, 2, 3]
res = [id(lst)] + [id(lst.append(i)) for i in lst]
print(res)

Author: SandhyaR | Tags: list | 1736+ Python FAQs | Share
boolean | memory | logical-operator | global-variable | encoding | command-line-parsing | operator-overloading | print | head-and-tail | goto-function | string-iteration | string-method | invalid-list | constructor | call | lists | variable | pandas | collection | keyword | format | multiprocessing | assert | init | raise | match | identity-operator | sum-function | module | class-and-inheritance | heap-memory | loop | design-principle | list-method | debugging | touples | list-join | loop-control | multithreading | exception-handling | odd-number | file_handling | recurssion | version-check | function | conversion | mapping-function | math | asyncio-module | assignment-operator | bitwise | dictionaries | inheritance | docstring | mysql | string | exponentiation | software-design | python-history | zfill-function | while-else-loop | python-django | python_version | print-statement | basic | recursion | polymorphism | join | binary | type-conversion | string-formatting | rollback | encapsulation | bitwise-operator | math-copysign | built-in-function | scientific-notation | comment | library | class | memory-management | application | while-loop | syntax-error | lambda-function | control-flow | object-attribute | name-mangling | operand | function-and-scope | with-statement | dictionary | numeric | data_structure | floating-point-precision | else-statement | __init_subclass__ | oops | def | data-structures | decimal | parameter | exception-handling | file-handling | python-repl | compute | condition | generator | objects | function-argument | syntaxerror | virtual-environment | complex-number | asyncio | lambda | id-function | datetime | mutable | installation | import-method | zip-function | binary-operation | arithmetic-operation | statement | functions | array | regular-expression | tuple-unpacking | indexing | postfix | destructor | immutability | access-modifier | string-concatenation | data-type | round | python | error-handling | attribute | input-function | zip | logical-operation | syntax | deep-copy | lambdas | thread | list-slicing | factorial-function | swapping | precedence | overflow | python-module | namespace | functional-programming | __future__ | filter | class-and-object | integer | classes | identifier | identity-operator | yield | collections | escape-operator | static-method | generators | file | pep | loops | dicts | logical-operator | data-type | built-in | staticmethod | center | immutable-data-type | list-vs-tuple | version | string-formatting | sum() | sorting | default-mutable-argument | mathematics | slice | input-function | indentation | formal-and-actual-parameter | choice | package-management | random | int | complex | turtle | return-statement | global-keyword | string-method | stack | type-conversion | feature | magic-method | update | error | __all__-attribute | counter | context-manager | namedtuple | matrix | method | conditional-statement | operator-or | type_conversion | min-max-function | syntax-error | bitwise-operator | filter-function | tuple | split | async | list-operation | list | copy | higher-order-function | round-function | operator-and | datatype | list-comprehension | set-operation | mathematical-function | generators-in-python | range | class-and-instance-variable | min-function | regex | threading | virtual-environment | built-in-function | shallow-copy | counter-function | gil | implementation | data-structure | comprehension | methods | sys | benefit | arithmetic-expression | append | exception | fabs-function | global-variable | string-manipulation | list-mutation | control-statement | matplotlib | iterable | expression | descriptors | frozenset | conditional-statement | max-min | typeerror | inherit | pickling-&-unpickling | pseudocode | operators | input | global | random-function | oop | nested-loop | sorted | enumerate() | comparison | numpy | string-slicing | operator | for | while-and-for-loop | list-comprehension | data-structure | boolean-and-non-boolean | multiple-inheritance | slicing | list-indexing | operations | precedence-and-associativity | string-slicing | expand-tab | control-flow | file-handling | map-function | interpreter | decorator | iterator | sys-module | set | matrix-list-comprehension ...