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