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