Level 6 : What will be the output of the following Python code?


list1 = [1, 3]
list2 = list1
list1[0] = 4
print(list2)

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