Level 1 : What does this code output?


lst = [0, 1, 2, 3, 4]
idx = lst.index(2)
lst[idx:idx+1] = [10, 20, 30]
print(lst)

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