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