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