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