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