Level 3 : What will this code output?


lst = [1, 2, 3, 4]
for i in range(len(lst)):
    lst.insert(i, lst.pop())
print(lst)

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