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